When attempting to import the requests module in Python 3.4.0 I receive the following error: ImportError: No module named 'requests'
The requests
module in previous version of Python required that you use pip
separately. But according to the new features in Python 3.4.0, pip
is built in: https://docs.python.org/3.5/whatsnew/3.4.html#whatsnew-pep-453
My import line is simply:
import requests
I am confused as to why this is not working. All help is greatly appreciated.
Having pip
included is meant to ease retrieving new packages. It does not state that all modules reachable through pip are bundled in new Python (hopefully !).
You are still required to pip install requests
before using the package requests
.
Edit: following another question, it seems dependencies on requests are flawed. Then try:
pip install chardet2 urllib3
as suggested by mentioned SO question.
Although pip
is built-in, you still have to call pip install requests
. pip
is just the tool for downloading, not the actual item. To download, use the following:
bash-3.2$ pip install requests
Downloading/unpacking requests
Downloading requests-2.2.1-py2.py3-none-any.whl (625kB): 625kB downloaded
Installing collected packages: requests
Cleaning up...
...
You don't have to install pip
, but you still have to use it to install other items.
Answering your comment, run the pip install
again, this time with a sudo
. You should see the following message:
$ sudo pip install requests
Password:
Requirement already satisfied (use --upgrade to upgrade): requests in /Library/Python/2.7/site-packages/requests-2.1.0-py2.7.egg
Cleaning up...
Or something of the likes. Then run this:
>>> import requests
>>> requests
<module 'requests' from '/Library/Python/2.7/site-packages/requests-2.1.0-py2.7.egg/requests/__init__.pyc'>
>>>
If the import
fails, go to the above directory and search for the files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With