Reputation: 709
Ive used pip to install requests but when i run my scrpit i get an import error.
I have also tried installing from github but still same issue.
Here is output
Successfully uninstalled requests-2.18.4
osx:shane shane$ sudo -H pip install requests
Collecting requests
Using cached requests-2.18.4-py2.py3-none-any.whl
Requirement already satisfied: urllib3<1.23,>=1.21.1 in /usr/local/lib/python2.7/site-packages (from requests)
Requirement already satisfied: idna<2.7,>=2.5 in /usr/local/lib/python2.7/site-packages (from requests)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python2.7/site-packages (from requests)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python2.7/site-packages (from requests)
Installing collected packages: requests
Successfully installed requests-2.18.4
osx:shane shane$ python scraper.py
Traceback (most recent call last):
File "scraper.py", line 1, in <module>
import requests
ImportError: No module named requests
what am i doing wrong ?
sys.path output
print sys.path
['', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lxml-3.6.0-py2.7-macosx-10.6-intel.egg']
Upvotes: 2
Views: 5086
Reputation: 1413
Use python -m pip install requests
to install requests.
This downloads requests
to the same python that is run on the shell.
Upvotes: 4