Installing and Updating Pip
00:00 Before we continue, I want to make sure you actually have a working pip install at this point, and that it’s fully up to date. So let’s talk about installing pip if it’s not already on your system and then also how you can upgrade to the latest version of pip.
So all modern versions of Python 2 and Python 3 are going to include pip by default. Now of course that doesn’t really help you if the
pip command doesn’t work in your system right now, so let’s talk about what you can do if pip is not available on your system yet.
00:40 Now, this would be my preferred option, but of course, if you’re working with older legacy versions of Python and you have a bunch of code running on them already, then that isn’t really the best option.
So, option two would be to add pip to your existing Python install, and that is definitely possible, I am going to show you how to do that now. So in a nutshell, on macOS and Windows, you would have to download a so called bootstrap script, called
To do that, you would first run a command like
sudo apt update to refresh your system’s package manger and then you would follow up with
sudo apt install python-pip, and running that command would add pip to your existing Python install.
01:57 Now adding pip to an existing Python install is a little bit fiddly, there are a couple of edge cases you need to look out for, one resource that I can recommend to learn more about how to do this, is the Python packaging guide.
02:11 You can find it at packaging.python.org. Let’s make sure you’re running an up to date version of pip on your system. Modern versions of Python will always include the latest pip version that came out when the Python release was prepared.
02:25 But, pip and Python are actually fully independent, so you can update pip without updating Python for example. Depending on the operating system that you’re on, the steps you need to take to update pip are slightly different.
02:50 On a Linux system where you are using the system package manager to manage your Python install, you would typically upgrade pip through that, so you wouldn’t actually use the pip command to upgrade pip but you would just tell the system package manager to update your install of pip.
I am going to give you a live demo of how that upgrade process works. So I am back here in my macOS terminal and I’ve prepared this command here, so I am running this command,
sudo pip install --upgrade pip setuptools.
So typically, you would update both of them at the same time. I am going to go ahead and run this command now, so because I am running this with
sudo, I need to enter my account password, okay, so this worked, and what pip is telling us here is that essentially everything is up to date.
03:51 So any time you want to update pip to the latest version in the future, you would just rerun that command, and then if there is an update pip would install it and upgrade itself to the latest version.
Become a Member to join the conversation.