I want to use python3.5 for development, but many times when I install the module for python 3.5, it always fails. The terminal tells me that a higher version is available, but it doesn't work when I upgrade it.

- 3,807
- 3
- 33
- 50

- 1,407
- 2
- 10
- 4
-
7You missed out a `3` in your second command – Moon Cheesez Jul 27 '16 at 12:43
-
5Unluckily,it not work neither pip3 install --upgrade pip not pip install --upgrade pip3. – EdgarX Jul 27 '16 at 12:51
-
Could you post the new error message for `pip3`? – Moon Cheesez Jul 27 '16 at 12:52
-
I try again,it works,thank you! – EdgarX Jul 27 '16 at 12:58
-
Doesnt work for pip3 – nik Jun 17 '19 at 02:28
12 Answers
You are using pip3 to install flask-script which is associated with python 3.5. However, you are trying to upgrade pip associated with the python 2.7, try running pip3 install --upgrade pip
.
It might be a good idea to take some time and read about virtual environments in Python. It isn't a best practice to install all of your packages to the base python installation. This would be a good start: http://docs.python-guide.org/en/latest/dev/virtualenvs/

- 1,645
- 1
- 10
- 9
-
1pip3 install --upgrade pip will only upgrade pip for python2 not pip3. – Nathan McKaskle Dec 07 '20 at 15:56
-
@NathanMcKaskle no it won't, I just tested it.. (but i tested it while being in the pip3 local directory) – Dany Balian Feb 01 '21 at 23:46
To upgrade your pip3, try running:
sudo -H pip3 install --upgrade pip
Your pip may move from /bin
to /usr/local/bin
To upgrade pip as well, you can follow it by:
sudo -H pip2 install --upgrade pip

- 5,414
- 6
- 40
- 72

- 1,245
- 2
- 10
- 12
-
2Worked flawlessly, whilst all other pip3 install --user --upgrade pip/pip3 failed. Thanks. – Fiddy Bux Apr 10 '18 at 10:24
-
2
-
wrong, pip3 install --upgrade pip will only install the upgrade for pip, not pip3. – Nathan McKaskle Dec 07 '20 at 15:56
-
@NathanMcKaskle no it won't, I just tested it.. (but i tested it while being in the pip3 local directory, i don't know if it makes a difference, just wanted to be sure) – Dany Balian Feb 01 '21 at 23:47
-
2`sudo pip3 install --upgrade pip` worked for me on amazon linux 2 but it changed the location of the binary. I updated the answer. – SomeGuyOnAComputer Mar 03 '21 at 20:55
-
You need to be very careful when using `sudo` with pip. See [What are the risks of running 'sudo pip'?](https://stackoverflow.com/questions/21055859/what-are-the-risks-of-running-sudo-pip) – Josh Correia Feb 24 '22 at 23:37
Try this command:
pip3 install --upgrade setuptools pip

- 1,581
- 2
- 18
- 25
-
2My windows 10 command line suggested `c:\python3\python3.exe -m pip install --upgrade setuptools pip` – XuMuK Feb 05 '19 at 13:46
-
1
-
7
-
1`sudo python3 -m pip uninstall pip && sudo apt install python3-pip --reinstall` solved the ImportError problem for me. Environment is ubuntu 18.04, it happened when I tried to upgrade pip3 (9 -> 19) on python 3.6. The snippet is from [Anthony Sottile](https://stackoverflow.com/a/49836753/8626681) – Sujoung Baeck Oct 16 '19 at 18:55
-
First decide which pip you want to upgrade, i.e. just pip or pip3. Mostly it'll be pip3 because pip is used by the system, so I won't recommend upgrading pip.
The difference between pip and pip3 is that
NOTE: I'm referring to PIP that is at the BEGINNING of the command line.
pip is used by python version 2, i.e. python2
and
pip3 is used by python version 3, i.e. python3
For upgrading pip3: # This will upgrade python3 pip.
pip3 install --upgrade pip
For upgrading pip: # This will upgrade python2 pip.
pip install --upgrade pip
This will upgrade your existing pip to the latest version.
-
wrong, pip3 install --upgrade pip will only install the upgrade for pip, not pip3. – Nathan McKaskle Dec 07 '20 at 15:57
-
Mac ships with python v2.7, but most of the developers tend to use Python v3.x, So pip3 is explicitly used to upgrade python3 package manager, and not python2 i.e shipped by Mac. https://stackoverflow.com/a/46424582/8972021 Martin has also explained here. – Feb 17 '21 at 17:39
The Problem
You use pip
(the Python 2 one). Now you want to upgrade pip
(the Python 3 one). After that, pip
is the Python 3 one.
The solution
Use pip2
and pip3
. This way it is explicit.
If you want to use pip
, just check where it is (which pip
) and change the link. For example:
$ which pip
/usr/local/bin/pip
$ pip --version
pip 9.0.1 from /usr/local/lib/python3.5/dist-packages (python 3.5)
$ which pip2
/usr/local/bin/pip2
$ sudo rm /usr/local/bin/pip
$ sudo ln -s /usr/local/bin/pip2 /usr/local/bin/pip
$ pip --version
pip 9.0.1 from /usr/local/lib/python2.7/dist-packages (python 2.7)

- 124,992
- 159
- 614
- 958
for Python 3:
python3 -m pip install --upgrade pip
for Python 2:
python2 -m pip install --upgrade pip

- 207
- 2
- 2
What worked for me was the following command:
python -m pip install --upgrade pip

- 101
- 3
- 5
In Ubuntu 18.04, below are the steps that I followed.
python3 -m pip install --upgrade pip
For some reason you will be getting an error, and that be fixed by making bash forget the wrongly referenced locations using the following command.
hash -r pip

- 25,512
- 7
- 93
- 64
If you have 2 versions of Python (eg: 2.7.x and 3.6), you need do:
- add the path of 2.x to system PATH
- add the path of 3.x to system PATH
pip3 install --upgrade pip setuptools wheel
for example, in my .zshrc file:
export PATH=/usr/local/Cellar/python@2/2.7.15/bin:/usr/local/Cellar/python/3.6.5/bin:$PATH
You can exec command pip --version
and pip3 --version
check the pip from the special version. Because if don't add Python path to $PATH, and exec pip3 install --upgrade pip setuptools wheel
, your pip will be changed to pip from python3, but the pip should from python2.x

- 47,830
- 31
- 106
- 135

- 11
- 3
This worked for me (mac)
sudo curl https://bootstrap.pypa.io/get-pip.py | python

- 232
- 4
- 11
If you try to run
sudo -H pip3 install --upgrade pip3
you will get the following error:
WARNING: You are using pip version 19.2.3, however version 21.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
but if you upgrade using the suggested command:
pip install --upgrade pip
then, the legacy pip will be upgraded, so what I did is the following:
which pip3
and I located my pip3 installation (just in case the following command wouldn't upgrade the legacy pip. Then i changed to that directory and upgraded pip3 using the following commands: (your directory could be different)
cd /Library/Frameworks/Python.framework/Versions/3.8/bin
sudo -H pip3 install --upgrade pip
after this:
pip --version
will still show the legacy version, while
pip3 --version
will show pip 21.0.1

- 608
- 7
- 16