ImportError: No module named json

13,988

I solved this. Although all the path variables were pointing to the right folders, windows was running python with a version that was installed within Lyx (that I did not know was there) and which did not have many of the Python modules. I managed to fix this from the control panel.

Share:
13,988
Nicolò Cavalleri
Author by

Nicolò Cavalleri

Updated on June 25, 2022

Comments

  • Nicolò Cavalleri
    Nicolò Cavalleri almost 2 years

    While installing a c++ library I ran into a Python problem (and I do not know nothing about this language). While running some Python code the shell gives me the following error:

    Traceback (most recent call last):
      File "C:\C++_libraries\v8\tools\dev\v8gen.py", line 54, in <module>
        import mb
      File "C:\C++_libraries\v8\tools\mb\mb.py", line 37, in <module>
        import json
    ImportError: No module named json
    

    I am using python 2.7.6 and I'm almost sure json is installed - I have a folder Lib/json containing the following files:

    __init__.py  __init__.pyc  decoder.py  decoder.pyc  encoder.py  encoder.pyc  scanner.py  scanner.pyc  tool.py
    

    When I run import json from the cmd it seems to work:

    c:\C++_libraries\v8\tools\dev>python
    Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import json
    >>> print(json.__file__)
    C:\depot_tools\python276_bin\lib\json\__init__.pyc
    

    I tried substituting the code line import json with import simplejson as json but then it says

    no module named simplejson

    (of course I also installed simplejson). I really do not know what else I can try.

    Thanks in advance.