Managing Python Dependencies Transcripts
Chapter: Managing Third-Party Dependencies With pip
Lecture: Uninstalling Packages

Login or purchase this course to watch this video and the rest of the course contents.
0:01 What do you do if you've installed the Python package, but you want to uninstall it and completely remove it from your system?
0:08 For example, if you've installed a package just to try it out how do you undo that, how do you uninstall the package? Let's talk about that now.
0:16 You can uninstall packages and remove them from your system using the pip uninstall command, this command is really similar to the pip install command,
0:25 you just go pip uninstall and the name of the package and pip will remove the package from your system.
0:31 Here is a quick demo; you can see here that I've got the Requests package installed. Let's remove it. Once I triggered the uninstall command,
0:43 pip is going to ask me if I really want to remove this package, so at this point I can still cancel the process,
0:48 and no change will be made to my system, so I am going to go yes here, and hit return, alright, and that's it, you successfully uninstalled Requests.
0:56 Let's make sure it's actually gone. As you can see, Requests no longer shows up in this list of installed packages.
1:06 You just saw how uninstalling a package through pip removed the package itself.
1:12 However, the question remains whether that also removes dependent packages, or in other words, will uninstalling a package also remove
1:22 the secondary dependencies off this package, and the answer is no, so pip uninstall will not uninstall secondary dependencies,
1:31 therefore, it isn't that easy to keep your Python environment nice and clean,
1:35 this is why I recommend that you use virtual environments as much as possible,
1:39 there is a whole section in this course dedicated to virtual environments, but in short, there are way for you to create new Python environments
1:47 that are completely separate from your global environment, so you can install packages without cluttering up your global Python environment.
1:55 And if you're using virtual environments then removing packages and cleaning up all of the unneeded secondary dependencies is really easy,
2:04 you just delete the virtual environment and recreate it from scratch. And this will get rid of all the unneeded secondary dependencies.


Talk Python's Mastodon Michael Kennedy's Mastodon