Issue #736 resolved

ImportError when importing the 'json' standard Python module

Anonymous avatarAnonymous created an issue

When trying to 'import json' from within a 'python:' hg hook, I get an "ImportError: No module named json" error. This is despite 'json' being a standard Python library since version 2.6.

Comments (7)

  1. Anonymous

    Yes, this is for a custom hook. I've also tried copying json.py from the standard Python2.6 distribution, but it required the "decimal" library - so I've stopped there.

    Why not include the entire Python Standard Library? Will it increase the executable size by too much?

    If I understand correctly, my only option now is to execute the python hook as an external program. Am I correct?

  2. Steve Borho

    I usually need some indication that a package will have more than one user before I pull them into the installer.

    Your other two options while they are not included:

    1. collect the dependent packages into a folder and insert that folder into sys.path in your hook code before you import them.
    2. build your own installer with all the dependencies included, see thg-winbuild
  3. liorn

    I need the json package in order to communicate with an issue tracking tool, which provides access to issue details through a JSON/REST web service. I believe other people might have the same need.

    Meanwhile I will collect all the dependent classes to a folder, as suggested.

    Thanks.

  4. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.