Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does uninstalling a package with "pip" also remove the dependent packages?

People also ask

Does uninstalling pip remove packages?

Unfortunately, pip does not uninstall dependencies when you uninstall the original package.

How do I uninstall a package without dependencies?

The first “rpm -qa” lists all RPM packages and the grep finds the package you want to remove. Then you copy the entire name and run the “rpm -e –nodeps” command on that package. It will, without prompting for confirmation, remove that package but none of its dependencies.

How do I remove a package from dependencies?

To remove a dev dependency, you need to attach the -D or --save-dev flag to the npm uninstall, and then specify the name of the package. You must run the command in the directory (folder) where the dependency is located.

How do you remove an installed package using pip?

To uninstall the package system-wide using pip, first uninstall it locally, then run the same uninstall command again, with root privileges. In addition to the predefined user install directory, pip install --target somedir somepackage will install the package into somedir.


You can install and use the pip-autoremove utility to remove a package plus unused dependencies.

# install pip-autoremove
pip install pip-autoremove
# remove "somepackage" plus its dependencies:
pip-autoremove somepackage -y

No, it doesn't uninstall the dependencies packages. It only removes the specified package:

$ pip install specloud
$ pip freeze # all the packages here are dependencies of specloud package

figleaf==0.6.1
nose==1.1.2
pinocchio==0.3
specloud==0.4.5

$ pip uninstall specloud
$ pip freeze

figleaf==0.6.1
nose==1.1.2
pinocchio==0.3

As you can see those packages are dependencies from specloud and they're still there, but not the specloud package itself.

As mentioned below, You can install and use the pip-autoremove utility to remove a package plus unused dependencies.


i've successfully removed dependencies of a package using this bash line:

for dep in $(pip show somepackage | grep Requires | sed 's/Requires: //g; s/,//g') ; do pip uninstall -y $dep ; done

this worked on pip 1.5.4


I have found the solution even though it might be a little difficult for some to carry out.

1st step (for python3 and linux):

pip3 install pip-autoremove  

2nd step:

cd /home/usernamegoeshere/.local/bin/  

3rd step:

gedit /home/usernamegoeshere/.local/lib/python3.8/site-packages/pip_autoremove.py  

and change all pip(s) to pip3
4th step:

./pip-autoremove packagenamegoeshere  

At least, this was what worked for me ...