Occasionally, you’ll want to uninstall a package. The safest way to do this is by running
pip show on every package you have installed, ensuring that the package you want to uninstall does not show up in the
requires: line for any package.
Once you’re confident you can uninstall a package, you can do so with
pip uninstall. Later, if you discover that you’ve accidentally removed a dependency of another package, you can reinstall that package, and
pip will automatically redownload the missing dependency.
00:00 Occasionally, you’ll want to remove a package in your environment. Maybe you found a better package that does the same thing, or you just don’t recognize a package as a dependency and you want to remove it.
People have created tools to automate this process, but I’m not using them here to enforce the fact that it’s good to understand your dependency tree, particularly in small-to-medium sized applications, where that’s very doable. Once you’re confident you can uninstall a package, you can run
pip uninstall and then the name of the package. Press
y to confirm. You can also append
-y to the
uninstall command to suppress this confirmation prompt, just like this. Later on, if you discover that you accidentally deleted a dependency to another package, you can always re-install the broken package and it will automatically re-download just the missing dependency.
Become a Member to join the conversation.