views:

1437

answers:

3

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)

+2  A: 

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.

Hole
in that case, how to upgrade my existing 2.5 to 2.6?
cometta
An installer for Python 2.6.2 for Mac OS X is available here: http://python.org/ftp/python/2.6.2/python-2.6.2-macosx2009-04-16.dmg Apparently the installer creates a "Python 2.6" folder in the Applications folder containing a script to update your PATH so that running "python" at the command line runs the newly-installed Python 2.6 instead of the system-default Python 2.5: http://superuser.com/questions/29652/how-do-i-properly-update-python-on-mac-os-x/30154#30154
las3rjock
A: 

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

Andrew Walker
+3  A: 

You can also install simplejson.

bluszcz
Missing Link: http://pypi.python.org/pypi/simplejson/
S.Lott