Managing Python Dependencies Transcripts
Chapter: Managing Third-Party Dependencies With pip
Lecture: Identifying & Updating Outdated Packages
Login or
purchase this course
to watch this video and the rest of the course contents.
0:01
Another benefit of using a package manager is that
0:04
you can keep your packages and dependencies up to date.
0:07
Pip can identify outdated packages that have new versions available
0:10
and then also upgrade them to the latest version.
0:13
Let me show you how that works now.
0:16
I am going to set up some kind of demo scenario we can work with here.
0:19
So what I am going to do is I am going to install
0:21
an older version of the Requests library
0:24
so that we can then go ahead and upgrade it.
0:32
So I just installed Requests 2.0 which is
0:35
an older version of Requests at this moment.
0:38
What I am going to do next is I am going to ask pip to identify outdated packages;
0:47
you can do that with the familiar pip list command,
0:50
and by adding a --outdated switch to it,
0:54
so when I run this, it tells me exactly which packages
0:58
that I have currently installed are outdated and what the latest version is.
1:02
So in this case, I can tell that there is a newer version of Requests available.
1:06
Now, let's upgrade Requests to the latest version.
1:10
Again, I am using the pip install command,
1:13
but this time I am passing it a --upgrade switch.
1:19
And then I need to tell it which library to upgrade,
1:23
so in this case, it will be Requests.
1:27
this will first uninstall the outdated version of Requests,
1:31
and then install the latest version.
1:38
By the way, you could get the same results with the -u switch,
1:42
so that is just a shortcut for a --upgrade if you want to save some typing.
1:52
Let's make sure we actually upgraded to the latest version of Requests.
1:56
I am going to run this pip list command with the --outdated switch again.
2:02
Alright, this time, there are no more outdated dependencies,
2:05
and I just successfully upgraded Requests to the latest version.