Often times you may need to upgrade PIP. In this short tutorial, I’ll show you the steps to upgrade PIP in Windows from scratch.
Here are the topics to be reviewed:
- Upgrade PIP in Windows
- Check the version of PIP
- Simple tool to upgrade PIP
- Downgrade PIP to a previous version
I recently became aware that I needed to upgrade PIP when I was trying to install a Python package using PIP.
I received the following notification:
You are using pip version 19.1.1, however version 19.2.3 is available. You should consider upgrading via the ‘python -m pip install –upgrade pip’ command.
In order to upgrade PIP in Windows, you’ll need to open the Windows Command Prompt, and then type/copy the command below. Note that the following method would only work if you already added Python to Windows path. Don’t worry if you don’t know what it means, as I’ll show the full steps to upgrade pip in windows in the next section.
python -m pip install --upgrade pip
Steps to upgrade PIP in Windows
(1) First, type Command Prompt in the Windows search box:
(2) Right click on the Command Prompt, and then select Run as administrator (by running the Command Prompt as an administrator, you’ll avoid any permission issues):
(3) In the Command Prompt, type “cd\” to ensure that your starting point has only the drive name:
(4) Press Enter, and you’ll see the drive name C:\>
(5) Locate your Python application path, which is the folder where you originally installed Python.
In my case, the Python application path is:
Once you retrieved the Python application path, type the following command in the Command Prompt:
“cd” and then your Python application path
In my case, I typed:
(6) Press Enter, and you’ll see:
(7) To upgrade PIP, type/copy this command, and then press Enter:
python -m pip install --upgrade pip
This is how the command would look like in the Command Prompt:
(8) You’ll notice that the latest version of PIP will be installed:
Steps to check the version of PIP
To check the version of PIP at any time, you’ll need to use the Python Scripts path, rather than the Python application path.
(1) First, type “cd\” to ensure that your starting point has only the drive name:
(2) Then, locate your Python Scripts path. The Scripts folder should be located within the Python application path.
In my case, the Python Scripts path is:
(3) Type “cd” followed by the Python Scripts path (then press Enter):
(4) Finally, type the following command to check the version of PIP:
(5) Press Enter, and you’ll see the PIP version:
Simple tool to upgrade PIP in Windows
In this section of the tutorial, I’ll share with you the code to upgrade PIP using a simple tool I created.
Note that you’ll need to add Python to Windows path in order to start using the tool.
Here is the complete Python code:
import os import tkinter as tk root= tk.Tk() canvas1 = tk.Canvas(root, width = 300, height = 350, bg = 'lightsteelblue2', relief = 'raised') canvas1.pack() label1 = tk.Label(root, text='Upgrade PIP', bg = 'lightsteelblue2') label1.config(font=('helvetica', 20)) canvas1.create_window(150, 80, window=label1) def upgradePIP (): os.system('start cmd /k python.exe -m pip install --upgrade pip') button1 = tk.Button(text=' Upgrade PIP ', command=upgradePIP, bg='green', fg='white', font=('helvetica', 12, 'bold')) canvas1.create_window(150, 180, window=button1) root.mainloop()
Simply, run the code, and then press on the button ‘Upgrade PIP’ and you should be good to go.
Now, what if you’d like to revert back to a previous version of PIP?
You can easily downgrade to a previous version of PIP by following the steps below.
Steps to downgrade PIP to a previous version
(1) Get to the Python application path. If you are currently set to the Python Scripts path, you can simply type “cd..” (and then press Enter), and you would revert back to the Python application path:
(2) Let’s say that you want to downgrade the PIP version to 18.1
To do that, simply type the following command, and then press Enter:
python -m pip install pip==18.1
(3) You should now see the version of PIP that you specified:
If you’re using Anaconda, you may want to check this tutorial that explains how to upgrade PIP in Anaconda.
Finally, if you need to install PIP, you may wanna review the pip documentation.