2

I'm trying to install and use python for the first time, but I'm having problems using extern librairies.

/usr/bin/python /path/core/__init__.py  
Traceback (most recent call last):  
  File "/Users/fabienlamarque/Downloads/RedditAPI/core/__init__.py", line 6, in <module>   
    import requests  
ImportError: No module named requests   

Source code :

import requests
r = requests.get(r'path/.json')

As I surfed around trying to find answers, I found some people telling me to use pip, I indeed used pip and pip3 (with python 2.7.5 and python 3.4.2), the answer is always:

$ pip install requests
Requirement already satisfied (use --upgrade to
upgrade): requests in /usr/local/lib/python2.7/site-packages
Cleaning up...

Which seems like a good thing, I forced the reinstallation of the module several times, but I always have the same problem. My IDE tells me "No module named 'requests'" though.
What did I miss?

Thanks

6
  • 3
    Are you running the correct Python executable? Perhaps you have one in /usr/local/bin/python but are using /usr/bin/python? Commented Dec 20, 2014 at 12:25
  • You should look into virtualenvs, which make managing which packages are available for a specific project much easier. Commented Dec 20, 2014 at 12:27
  • Mmmmh upon further inspection, I got python 2.7.5 installed in /usr/local/bin and I have some python files in /usr/bin/ (python, python-config, python2, python-config) Commented Dec 20, 2014 at 12:33
  • What version number do you see if you just type python (and hit enter) in the shell? Commented Dec 20, 2014 at 12:36
  • Python 2.7.5 (default, Mar 9 2014, 22:15:05) Commented Dec 20, 2014 at 12:38

1 Answer 1

1

I see /usr/bin/python in there so it's a *nix variant.

you will probably find that which python and which pip point to different locations.

You can just download the source and use python setup.py install assuming that your user has write privilages to the puthon site-packages dir.

Virtualenv for virtualenvironments of even better, conda environments is soemthing I highly suggest learning early on to avoid these headaches on your leaning path.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.