Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Identifying and Updating Outdated Packages

00:00 Another benefit of using a package manager is that you can keep your packages and dependencies up to date. Pip can identify outdated packages that have new versions available and then also upgrade them to the latest version.

00:13 Let me show you how that works now. I am going to set up some kind of demo scenario we can work with here. So what I am going to do is I am going to install an older version of the Requests library so that we can then go ahead and upgrade it.

00:32 So I just installed Requests 2.0 which is an older version of Requests at this moment. What I am going to do next is I am going to ask pip to identify outdated packages; you can do that with the familiar pip list command, and by adding a --outdated switch to it.

00:54 So when I run this, it tells me exactly which packages that I have currently installed are outdated and what the latest version is. So in this case, I can tell that there is a newer version of Requests available.

01:06 Now, let’s upgrade Requests to the latest version. Again, I am using the pip install command, but this time I am passing it a --upgrade switch.

01:19 And then I need to tell it which library to upgrade, so in this case, it will be requests. This will first uninstall the outdated version of Requests, and then install the latest version.

01:38 By the way, you could get the same results with the -u switch, so that is just a shortcut for a --upgrade if you want to save some typing.

01:52 Let’s make sure we actually upgraded to the latest version of Requests. I am going to run this pip list command with the --outdated switch again.

02:02 Alright, this time, there are no more outdated dependencies, and I just successfully upgraded Requests to the latest version.

Paulo Szewierenko on July 20, 2020

Can updating a package conflict with dependencies? If so, how to overcome it?

Dan Bader RP Team on July 24, 2020

Dealing with conflicting dependencies can be a challenge and usually requires manual intervention.

Pip will attempt to install whatever packages and versions are listed in your requirements file, even if there are conflicting transitive dependencies.

There’s a pip check command that detects version conflicts, you can learn more about it here:

As far as specific steps you can take to resolve conflicts, check out this article with some more concrete examples.

Paulo Szewierenko on Sept. 30, 2020

Thanks Dan!

Become a Member to join the conversation.