0

I installed Python using Homebrew, I installed Pip and then using Pip I downloaded the Requests module.

Just to double check I tried to install it again and got a confirmation in terminal that it was already installed:

Requirement already satisfied: requests in /usr/local/lib/python2.7/site-packages

I then tried to write a pretty simple script to call Git and see if I can get a response. But when I run it I get an error message. Here's the script and message:

import requests

response = requests.get('https://api.github.com/events')

print (response)

Message:

PythonTesting/main.py", line 5, in <module>
    import requests
ImportError: No module named requests
5
  • Possible duplicate of "ImportError: no module named 'requests'" after installing with pip Commented Dec 9, 2016 at 21:17
  • Did you try pip install -U requests? Commented Dec 9, 2016 at 21:46
  • 1
    Wrong Python version? Installed for Python 2 and started Python 3? Commented Dec 9, 2016 at 21:57
  • try running python2.7 and then trying Commented Dec 10, 2016 at 8:28
  • Thanks for all the assist, couldn't reply yesterday because some genius scheduled a long afternoon meeting on a Friday...ug. The wrong version issue sounds like the correct answer, I know Apple ships with 2.7, I did an install yesterday of the latest so that must be the issue. Commented Dec 10, 2016 at 13:20

2 Answers 2

2

I'm a beginner in programming. Today, I was in the same problem. I spent many hours trying fix this problem. For me worked:

  • open prompt comand
  • cd (path of scripts directory in venv - my project on VisualStudio Code)
  • pip install requests Then, I opened VS and put my code to go. It's work well.
Sign up to request clarification or add additional context in comments.

Comments

0

Make sure you are running the code in version 2.7 as you have installed the request package for 2.7 only. If by mistake you are running the code on version 3, then that request package won't work. In that case, you need to install the requests for python3.

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.