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.
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.
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.
Become a Member to join the conversation.