I have pip 8.1 installed and I wanted to upgrade to > 9.0.1 (to install matplotlib for python 2.7). I saw How to upgrade pip to latest? and did
sudo -H pip3 install --upgrade pip
sudo -H pip2 install --upgrade pip
but after than, if I type pip --version
, I get
ckim@chan-ubuntu:~$ pip --version
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
from pip import main
ImportError: cannot import name main
This had I experienced before and I knew the solution(Hmm. sounds like German word order..:)) , so I did
sudo python3 -m pip uninstall pip && sudo apt install python3-pip --reinstall
sudo python -m pip uninstall pip && sudo apt install python-pip --reinstall
and then I type pip --version
and get
pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7)
This is back to 8.1.1. How can I upgrade to newest version?
ADD : I'm using 16.04.5 LTS. This in system environment.(ok in python 2.7 virtual environment)
The issue here is that the
pip
installed byapt
conflicts with the standardpip
packageThe easiest solution is to only install the standard
pip
:Uninstall
pip
by running the following until nothing happens:Uninstall
apt
pip
Download the
pip
boot-strap from https://bootstrap.pypa.io/get-pip.pypip
NB: replace
python
withpython3
if you're using Python 3, but the OP wantsmatplotlib
for Python 2The main difference between the
apt
pip
and the standardpip
is that--user
is the default onapt
, meaning packages will be installed to the user's packages directory: eg "~/.local/lib/python2.7/site-packages". Standardpip
will default to installing to the system packages directory. Edit:pip
v20 will install to the user directory if it doesn't have permissions to edit the system directoryAlso, the
apt
pip
tends to be many versions behind, lacking many features and bug-fixes that are in the current standardpip
(such as installation from private repositories, PEP-517 support, command-line autocompletion)Try with :