1

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.

5
  • 3
    What OS are you running? Are you sure pip isn't installed? If you're on *nix, try just running sudo pip install requests Commented Aug 8, 2016 at 18:38
  • 1
    You seem to be running OS X. Have you tried brew install pip, then pip install requests? Commented Aug 8, 2016 at 18:39
  • Mac OS Capitan. @SeanPianka ran brew install pip response: Error: No available formula with the name "pip" Homebrew provides pip via: brew install python. However you will then have two Pythons installed on your Mac, so alternatively you can install pip via the instructions at: https://pip.readthedocs.io/en/stable/installing/ Commented Aug 8, 2016 at 19:24
  • 2
    What about python -m pip install requests? Commented Aug 8, 2016 at 20:51
  • Thanks, executed, returned: No module named pip Commented Aug 8, 2016 at 22:24

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

4 Comments

This is a good platform independent solution (+1), but just as a note, for new programmers getting Pip up is usually a much easier and faster solution.
.... and also requires installation of pip. For most libraries, running setup.py directly works. But, your point is a good one.
Please see here for pip installation information, I've edited my answer with the tl;dr of it.
Solved, and installed requests. sudo python get-pip.py then executed sudo pip install requests Thanks!
1

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.