Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to add json library

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)

like image 318
cometta Avatar asked Sep 07 '09 12:09

cometta


3 Answers

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".

like image 58
bluszcz Avatar answered Sep 21 '22 17:09

bluszcz


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.

like image 38
Hole Avatar answered Sep 21 '22 17:09

Hole


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

like image 45
Andrew Walker Avatar answered Sep 18 '22 17:09

Andrew Walker