Reputation: 27285
I'm on a mac and have tried the following:
easy_install requests
and
pip install requests
When I try import requests
command in REPL python I get the following error
Python 2.7.5 (default, Mar 9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "requests.py", line 4, in <module>
from requests.auth import HTTPBasicAuth
ImportError: No module named auth
What am I doing wrong?
Upvotes: 0
Views: 17308
Reputation: 1124090
You have a local module named requests.py
in your current directory. Rename that file, it is masking the installed library.
What is happening in your traceback:
requests
and the first item on the sys.path
search path is a file named requests.py
, it fits the requirements.from requests.auth import HTTPBasicAuth
, Python tries to import that.requests
imported (from step 1), but since it is a plain module and not a package, an ImportError
is thrown.Upvotes: 6