ImportError: No module named urllib3 when installing pip

codyc4321 picture codyc4321 · Jun 23, 2016 · Viewed 13.3k times · Source

I have an issue with virtualenvwrapper that requires reinstalling pip as the first step, and I am getting a strange complaint about urllib3:

$ python get-pip.py 
Traceback (most recent call last):
  File "get-pip.py", line 19177, in <module>
    main()
  File "get-pip.py", line 194, in main
    bootstrap(tmpdir=tmpdir)
  File "get-pip.py", line 82, in bootstrap
    import pip
  File "/tmp/tmppQTQty/pip.zip/pip/__init__.py", line 16, in <module>
  File "/tmp/tmppQTQty/pip.zip/pip/vcs/mercurial.py", line 9, in <module>
  File "/tmp/tmppQTQty/pip.zip/pip/download.py", line 39, in <module>
  File "/tmp/tmppQTQty/pip.zip/pip/_vendor/requests/__init__.py", line 61, in <module>
  File "/tmp/tmppQTQty/pip.zip/pip/_vendor/requests/packages/__init__.py", line 29, in <module>
ImportError: No module named urllib3

when I search the pip file get-pip.py, I don't see any reference to urllib3.

I have python2.6, py2.7, and py3.4 on the machine

cchilders:~/Downloads 
$ which python
/usr/local/bin/python

cchilders:~/Downloads 
$ which pip
/usr/local/bin/pip


cchilders:/usr/local/bin 
$ ls
2to3           easy_install-2.7  ipython   pip3              smtpd.py
celery         fop               ipython2  pip3.5            uncompyle2
celerybeat     grunt             jsonlint  pydoc             virtualenv
celeryd        idle              pbr       python            virtualenv-clone
celeryd-multi  ipdb              pip       python2.6         virtualenvwrapper_lazy.sh
charm          iptest            pip2      python2.6-config  virtualenvwrapper.sh
easy_install   iptest2           pip2.7    python-config

Python is defaulting to 2.6.9 which isn't what I want:

cchilders:/usr/bin 
$ python
Python 2.6.9

I do not have anaconda on the machine, which caused someone else's problem. Any advice what to do now appreciated, thank you

Answer

Marthanda Anand picture Marthanda Anand · Nov 11, 2016

Very first you should to know what default python version you are using then, suppose if you are using python2.7 then try to find installed pip packages under that python version using pip freeze or pip freeze | grep -i urllib3

i guess urllib3 is not installed

wget https://pypi.python.org/packages/3b/f0/e763169124e3f5db0926bc3dbfcd580a105f9ca44cf5d8e6c7a803c9f6b5/urllib3-1.16.tar.gz#md5=fcaab1c5385c57deeb7053d3d7d81d59
tar xvf urllib3-1.16.tar.gz  && cd urllib3-1.16/
python setup.py install