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,
0:04 but you want to uninstall it and completely remove it from your system?
0:07 For example, if you've installed a package just to try it out how do you undo that,
0:11 how do you uninstall the package? Let's talk about that now.
0:15 You can uninstall packages and remove them from your system
0:18 using the pip uninstall command,
0:21 this command is really similar to the pip install command,
0:24 you just go pip uninstall and the name of the package
0:27 and pip will remove the package from your system.
0:30 Here is a quick demo; you can see here that I've got the Requests package installed.
0:34 Let's remove it.
0:39 Once I triggered the uninstall command,
0:42 pip is going to ask me if I really want to remove this package,
0:45 so at this point I can still cancel the process,
0:47 and no change will be made to my system,
0:49 so I am going to go yes here, and hit return,
0:52 alright, and that's it, you successfully uninstalled Requests.
0:55 Let's make sure it's actually gone.
0:59 As you can see, Requests no longer shows up in this list of installed packages.
1:05 You just saw how uninstalling a package through pip removed the package itself.
1:11 However, the question remains whether that also removes dependent packages,
1:17 or in other words, will uninstalling a package also remove
1:21 the secondary dependencies off this package,
1:24 and the answer is no, so pip uninstall will not uninstall secondary dependencies,
1:30 therefore, it isn't that easy to keep your Python environment nice and clean,
1:34 this is why I recommend that you use virtual environments as much as possible,
1:38 there is a whole section in this course dedicated to virtual environments,
1:42 but in short, there are way for you to create new Python environments
1:46 that are completely separate from your global environment,
1:49 so you can install packages without cluttering up your global Python environment.
1:54 And if you're using virtual environments then removing packages
1:57 and cleaning up all of the unneeded secondary dependencies is really easy,
2:03 you just delete the virtual environment and recreate it from scratch.
2:06 And this will get rid of all the unneeded secondary dependencies.