Pip: No Module Found Urllib3 for every single command in PIP

Created on 28 Mar 2016  路  13Comments  路  Source: pypa/pip

My Pip was working fine. Then I tried to install a software that requires python modules etc. Now my pip does not even show help menu. It keeps posting same error in command line Import Error: No module named urllib3.

I tried to install urllib3. I couldn't manage to download it manually. Because preferred method of the installation was though pip install urllib3.

What I've run: Nothing works.



Same error that I get every single try.

Tuncs-MacBook-Pro:local morova$ pip install urllib3
ERROR:root:code for hash md5 was not found.
Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type md5
ERROR:root:code for hash sha1 was not found.
Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha1
ERROR:root:code for hash sha224 was not found.
Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha224
ERROR:root:code for hash sha256 was not found.
Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha256
ERROR:root:code for hash sha384 was not found.
Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha384
ERROR:root:code for hash sha512 was not found.
Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha512
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 7, in <module>
    from pip import main
  File "/usr/local/lib/python2.7/site-packages/pip/__init__.py", line 15, in <module>
    from pip.vcs import git, mercurial, subversion, bazaar  # noqa
  File "/usr/local/lib/python2.7/site-packages/pip/vcs/mercurial.py", line 9, in <module>
    from pip.download import path_to_url
  File "/usr/local/lib/python2.7/site-packages/pip/download.py", line 39, in <module>
    from pip._vendor import requests, six
  File "/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/__init__.py", line 58, in <module>
    from . import utils
  File "/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/utils.py", line 26, in <module>
    from .compat import parse_http_list as _parse_list_header
  File "/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/compat.py", line 7, in <module>
    from .packages import chardet
  File "/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/__init__.py", line 29, in <module>
    import urllib3
ImportError: No module named urllib3

Thank you for your help,

Best,

Tunc

auto-locked

Most helpful comment

reason:

  • env: mac osx 10.12.6 + Python2.7.13 + requests (2.12.4)
  • you guys should check openssl version.
  • the mac osx default openssl version is 0.9.8zh 14 Jan 2016.
  • when you use brew install openssl, the current version is stable 1.0.2l.
  • but if you use brew install [email protected], this version will Cause No Module Found Urllib3 issue.

How to fix:

brew uninstall [email protected]

# openssl: stable 1.0.2l
brew install openssl

  • then, you will find Urllib3 issue is fixed.

@mortunco @olaputin

All 13 comments

I've got the same problem.
Have you any update?

I dont remember exactly what I did, however, I think I removed pip with brew uninstall and re installed. It solved my problem.

Sorry :(

I have a number of users reporting this at certbot/certbot#2902.

This doesn't look like a pip issue, it looks like you've somehow gotten your Python installation into a really bad state.

This is a problem with the python 2 ensurepip module - it doesn't install urllib3 which pip depends on.

pip doesn't depend on anything directly, if your pip does it's because your vendor has modified pip to make it do so. I would suggest raising an issue with whoever you get your Python from.

 % ./python2 ./pip2.7 --version
Traceback (most recent call last):
  File "./pip2.7", line 7, in <module>
    from pip import main
  File "/tmp/tmptjo9pcss/fake-Python-2.7.13/opt/CORP/python2.7/lib/python2.7/site-packages/pip/__init__.py", line 21, in <module>
    from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
  File "/tmp/tmptjo9pcss/fake-Python-2.7.13/opt/CORP/python2.7/lib/python2.7/site-packages/pip/_vendor/requests/__init__.py", line 62, in <module>
    from .packages.urllib3.exceptions import DependencyWarning
  File "/tmp/tmptjo9pcss/fake-Python-2.7.13/opt/CORP/python2.7/lib/python2.7/site-packages/pip/_vendor/requests/packages/__init__.py", line 29, in <module>
    import urllib3

This is with the pip installed by the python ensurepip module, called by the configure --with-ensurepip=install.
So, it does depend on urllib3, via requests it looks like, and the ensurepip module isn't doing a proper job of installing the dependencies. Doing an easy_install urllib3 lets pip run properly. I'm guessing though that it's the cpython guys that would be responsible for ensurepip.

Sorry, to be more clear pip uses urllib3 (via requests), but we don't depend on it in the typical way. We copy it into pip/_vendor so that it becomes part of our code base instead of needing to have urllib3 installed in the typical way.

Looking at your specific traceback, it could also be that the bundled urllib3 is failing it's import in some way. You can see this code here: https://github.com/pypa/pip/blob/master/pip/_vendor/requests/packages/__init__.py#L26-L30

It should be finding the bundled copy of urllib3 and not falling back at all, but presumably that is raising an ImportError for some reason. Making a small modification to add a raise statement before the import urllib3 will probably give you the real, underlying cause.

reason:

  • env: mac osx 10.12.6 + Python2.7.13 + requests (2.12.4)
  • you guys should check openssl version.
  • the mac osx default openssl version is 0.9.8zh 14 Jan 2016.
  • when you use brew install openssl, the current version is stable 1.0.2l.
  • but if you use brew install [email protected], this version will Cause No Module Found Urllib3 issue.

How to fix:

brew uninstall [email protected]

# openssl: stable 1.0.2l
brew install openssl

  • then, you will find Urllib3 issue is fixed.

@mortunco @olaputin

my case:
I build python2.7 with openssl(enable ssl2 ssl3) for security testing!

standard build openssl without -fPIC.
i get error:

ImportError: No module named urllib3

last, build openssl with -fPIC.
./config --prefix=pwd/local enable-ssl2 enable-ssl3 no-shared -fPIC

error fix .

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings