How to upgrade pip3?

How to upgrade pip3?

I want to use python3.5 to develop basically,but many times when i install the module for the python3.5,it always failed.And the termimal told me that higher version is available,it did not work when I upgrade it.


Solution 1:

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:

Solution 2:

Try running sudo -H pip3 install --upgrade pip to upgrade your pip3.
Conversely, you can do sudo -H pip2 install --upgrade pip to upgrade pip as well.

Solution 3:

Try this command:

pip3 install --upgrade setuptools pip

Solution 4:

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

$ pip --version
pip 9.0.1 from /usr/local/lib/python3.5/dist-packages (python 3.5)

$ which 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)

Solution 5:

What worked for me was the following command:

python -m pip install --upgrade pip

Solution 6:

If you have 2 versions of Python (eg: 2.7.x and 3.6), you need do:

  1. add the path of 2.x to system PATH
  2. add the path of 3.x to system PATH
  3. 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