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

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds 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 the default subtitles language 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.

Uninstalling Packages

00:00 What do you do if you’ve installed the Python package, but you want to uninstall it and completely remove it from your system? 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.

00:15 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, you just go pip uninstall and the name of the package and pip will remove the package from your system.

00:30 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, pip is going to ask me if I really want to remove this package, so at this point I can still cancel the process, 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.

00:55 Let’s make sure it’s actually gone. As you can see, Requests no longer shows up in this list of installed packages. You just saw how uninstalling a package through pip removed the package itself.

01:11 However, the question remains whether that also removes dependent packages, or in other words, will uninstalling a package also remove the secondary dependencies of this package?

01:24 And the answer is no, so pip uninstall will not uninstall secondary dependencies. Therefore, it isn’t that easy to keep your Python environment nice and clean, this is why I recommend that you use virtual environments as much as possible, 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 that are completely separate from your global environment, so you can install packages without cluttering up your global Python environment.

01:54 And if you’re using virtual environments then removing packages and cleaning up all of the unneeded secondary dependencies is really easy, you just delete the virtual environment and recreate it from scratch.

02:06 And this will get rid of all the unneeded secondary dependencies.

Become a Member to join the conversation.