ImportError when importing the 'json' standard Python module

Issue #736 resolved
Anonymous 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 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.


  4. Log in to comment