Question

i am new to python, on my Mac, when i issue command

User:ihasfriendz user$ python main.py
Traceback (most recent call last):
  File "main.py", line 2, in <module>
    import json
ImportError: No module named json

I get error on json. how to add this library? i'm using 2.5 (the default came with leopard)

Was it helpful?

Solution

You can also install simplejson.

If you have pip (see https://pypi.python.org/pypi/pip) as your Python package manager you can install simplejson with:

 pip install simplejson

This is similar to the comment of installing with easy_install, but I prefer pip to easy_install as you can easily uninstall in pip with "pip uninstall package".

OTHER TIPS

AFAIK the json module was added in version 2.6, see here. I'm guessing you can update your python installation to the latest stable 2.6 from this page.

You can also install json-py from here http://sourceforge.net/projects/json-py/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top