How to upgrade pip3?

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


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:

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.

Try this command:

pip3 install --upgrade setuptools pip

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)

What worked for me was the following command:

python -m pip install --upgrade pip

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

pip3 install --upgrade pip worked for me

Need Your Help

How to flatten only some dimensions of a numpy array

python numpy flatten

Is there a quick way to "sub-flatten" or flatten only some of the first dimensions in a numpy array?

Moving Files In Google Drive Using Google Script

google-apps-script google-sheets google-drive-api

I'm trying to create documents using information posted through Google forms, then once the document is created I would like to move the document into a shared folder for people to view.