Reputation: 3348
When I try to compile I am getting the following error:
ImportError: No module named simplejson
So I tried:
pip install simplejson
And I am getting:
Requirement already satisfied (use --upgrade to upgrade): simplejson in /Library/Python/2.7/site-packages
Cleaning up...
I tried uninstalling it and installing it again and the same error.
I am running python 2.7.9
on OS Yosemite
Any idea what can I do? Thanks in advance
Upvotes: 2
Views: 7749
Reputation: 667
See my answer here. The short version is to make sure the version of pip you're using (2 vs 3) is the same as the version of python you're using. The commands you want are
pip2 install simplejson
if you're using python 2 and
pip3 install simplejson
if you're using python 3.
The full answer as mirrored from the link:
I had this same issue and it was not fixed by running pip install simplejson
despite pip insisting that it was installed. Then I realized that I had both python 2 and python 3 installed.
> python -V
Python 2.7.12
> pip -V
pip 9.0.1 from /usr/local/lib/python3.5/site-packages (python 3.5)
Installing with the correct version of pip is as easy as using pip2
:
> pip2 install simplejson
and then python 2 can import simplejson
fine.
Upvotes: 1
Reputation: 9
If you can't get your simplejson installation working, you can alternatively use the json library included in by default in Python 2.6+. If you're not concerned with small speed differences or backwards compatibility issues, the JSON library should be adequate and provides the same API. For more info on the differences between json and simplejson, check out this post.
You can also satisfy current dependencies on simplejson by changing your import statement from
import simplejson
to
import json as simplejson
Upvotes: 1