Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python3 pip3 install broken on Ubuntu

I installed python3 and pip3 successfully on my Ubuntu16.04, but pip3 install is broken. How can I fix this problem? The error info of pip3 install is as follows:

# pip3 install xlwt
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
  from pip import main
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 21, in <module>
  from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
ModuleNotFoundError: No module named 'pip._vendor.requests'

Output of "which pip3" and "pip3 --version":

# which pip3
/usr/bin/pip3

# pip3 --version
Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
    from pip import main
  File "/usr/lib/python3/dist-packages/pip/__init__.py", line 21, in <module>
    from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
ModuleNotFoundError: No module named 'pip._vendor.requests'

p.s. Python2 pip runs successfully. Output of "which pip" and "pip --version":

# which pip
/usr/bin/pip

# pip --version
pip 1.5.4 from /usr/local/lib/python2.7/dist-packages/pip-1.5.4-py2.7.egg (python 2.7)

And python and python3 installation information:

# which python
/usr/bin/python
# which python3
/usr/bin/python3

# python -V
Python 2.7.14
# python3 -V
Python 3.6.3

Any solution or clue will be appreciated! Thank you!

like image 282
mlpy Avatar asked Sep 28 '26 00:09

mlpy


1 Answers

This has happened to me multiple times before. A lot of the time, pip3 has issues installing with python3 by default, so try uninstalling and reinstalling pip3. Hope this works.

sudo apt-get remove python3-pip; sudo apt-get install python3-pip

EDIT: After doing some scouting about pip.vendor.requests, it seems like this is a very common error relating to SSL problems. If this line gives you errors in python (import ssl), some solutions can be found here: https://github.com/pypa/pip/issues/2345.

like image 185
Saransh Malik Avatar answered Sep 30 '26 15:09

Saransh Malik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!