jTank
jTank

Reputation: 33

Error when "import requests" - "No module named requests"

N00b Altert.

So I tried to call "import requests" through Python and got the error:

>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named requests

I do not think I have pip installed correctly or at all?

easy_install requests returns: The following error occurred while trying to add or remove files in the installation directory:

[Errno 13] Permission denied: '/Library/Python/2.7/site-packages/test-easy-install-6488.pth'

The installation directory you specified (via --install-dir, --prefix, or the distutils default setting) was:

/Library/Python/2.7/site-packages/

Any help on this would be greatly appreciated... I have seen the other posts with users mentioning the same but it doesn't seem to help.

Upvotes: 1

Views: 22311

Answers (2)

pundit
pundit

Reputation: 187

Type

import requests

Guide your cursor to the command (Donot press space) You will see a red bulb.There will be an option to install requests. Click it and done. This worked for me on Pycharm. Installing it through pip didnot help me.

Upvotes: 1

hd1
hd1

Reputation: 34677

According to the requests website installation page:

  1. Checkout the git repository
  2. execute /path/to/virtualenv/bin/python requests/setup.py install

As a third step, if you have problems doing this, please come back and leave a comment, such that I may help you further.

Your problem is a permissions problem. The solution I'd recommend is to pip install virtualenv and create a new environment for your project, installing requests in that environment.

To install pip, do a curl -kO https://bootstrap.pypa.io/get-pip.py and run it as python get-pip.py then install virtualenv as in the above paragraph.

Upvotes: 2

Related Questions