2

I know there are many posts on this, and I've tried using the solutions provided, but to no avail. I tried pip install requests and pip install requests --upgrade:

pip install requests --upgrade
You are using pip version 7.1.0, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Requirement already up-to-date: requests in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages

I then tried running pip install --upgrade pip, yet when I run my file I still get

Import Error: No module named requests

I am able to use requests in PyCharm, so I don't know what's causing this. Can someone please help?

10
  • 1
    reqeusts -> requests
    – Baart
    Commented Sep 29, 2015 at 8:35
  • I think you misspelled requests Commented Sep 29, 2015 at 8:35
  • There is indeed no module named reqeusts; you transposed the u and e (well spotted Baart). Commented Sep 29, 2015 at 8:35
  • @Martijn Pieters Yes, I typed it out wrong... Commented Sep 29, 2015 at 8:37
  • 1
    Sounds like you are running a different Python binary. What does import sys; sys.executable tell you you are using? Commented Sep 29, 2015 at 8:40

3 Answers 3

4

You installed requests into a different Python installation. The /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages is the site-packages directory for the Mac OS X /usr/bin/python installation.

PyCharm is not currently configured to use that Python installation; check what Python is being used either by looking at your PyCharm settings, or by asking Python directly with:

import sys
print(sys.executable)

Note that PyCharm can handle package installations for you as well; rather than use the command line pip consider using PyCharm, as it'll use the currently configured Python installation in that case.

2

install package name "request" from pychram package setting. then it will be work fine.

2
  • Hi, welcome to Stack Overflow. When answering an exceedingly old question that already has an answer, please be sure to add some additional insight into why the response you're providing is substantive and not simply echoing what's already been vetted by the original poster.
    – chb
    Commented Feb 24, 2019 at 6:29
  • @nazmul that's helped
    – Indian
    Commented Dec 27, 2019 at 9:55
2

If you are having this issue in Pycharm and you have configured your Pycharm to create projects in virtual environments, then you can use the Terminal in Pycharm to run the

pip3 install requests 

to resolve this issue. This is by design to ensure you control dependencies.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.