ImportError: No module named urllib3 when installing pip
Asked Answered
V

1

8

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

Volin answered 23/6, 2016 at 15:25 Comment(5)
Execute which python and then just python and import urllib3 and show us the output.Hydro
cchilders:~ $ which python /usr/local/bin/python cchilders:~ $ python Python 2.6.9 (unknown, Jun 20 2016, 14:36:39) [GCC 4.9.2] on linux3 Type "help", "copyright", "credits" or "license" for more information. >>> import urllib3 Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named urllib3 Volin
This might be an issue caused by having several /specific/ variants of Python installed at the same time, but I've never actually seen this happen. You aren't using Anaconda, are you? I would try reinstalling/upgrading Python. What OS are you using?Hydro
no anaconda. yes these issues started after installing py2.6.9 (required for testing one of our older projects). I'm also getting the obnoxious /usr/local/bin/python: No module named virtualenvwrapper Volin
Try using another python explicitly, see if it works. I'd tell you where to look but I'm not sure what OS you're using. Also, try reinstaling the Python instances and see if it helps.Hydro
R
3

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
Ringworm answered 11/11, 2016 at 6:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.