Search code examples
linuxpython-2.7pipfailed-installationurllib3

python urllib3 pip install error linux


I am trying to install urllib3 using pip and get the error posted at the bottom of this message.

I have wrestled with the issue for a few days days trying many things I have found online now without success, so I am finally posting here. Unfortunately I don't know quite enough to know which bits of what I have tried might be relevant, but here goes.

I want to install urllib3 because I am trying to create a simple twitter bot based on various tutorials I have found online, and I am regularly getting this error: 'ImportError: No module named urllib3'. I though I thought I had installed urllib3 (via synaptic - it says I have).

Prior to this, I was attempting to follow the advice here https://urllib3.readthedocs.org/en/latest/security.html#pyopenssl because I was initially getting the INsecurePlatformWarning at the bottom of the page, when trying to get the bot working. (Before attempting to install urllib3 I installed python-pip, then the following, using the command: 'pip install pyopenssl ndg-httpsclient pyasn1' as per the instructions on the page. This appears to have worked...

I see in the error the permissions denied/root statements but after trying various things I am not sure now how to fix it, even though I think it should be simple. I have tried uninstalling/re-installing various things. I would very much appreciate a point in the right direction..!

Thanks again, ronf.

The error:

ronf@debian:~/Downloads/twitterAPIstuff$ pip install urllib3
Collecting urllib3
  Using cached urllib3-1.10.4-py2-none-any.whl
Installing collected packages: urllib3
Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 223, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/site-packages/pip/commands/install.py", line 297, in run
    root=options.root_path,
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 622, in install
    **kwargs
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 808, in install
    self.move_wheel_files(self.source_dir, root=root)
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 1003, in move_wheel_files
    isolated=self.isolated,
  File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 339, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 310, in clobber
    ensure_dir(destdir)
  File "/usr/local/lib/python2.7/site-packages/pip/utils/__init__.py", line 70, in ensure_dir
    os.makedirs(path)
  File "/usr/local/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/site-packages/urllib3-1.10.4.dist-info'

Solution

  • As indicated in the last row, you don't have enough permission to execute the command. Try this (I assume that you're using Ubuntu/Debian):

    sudo pip install urllib3