How to remove a package installed with pip install --user

There is a --user option for pip that can install a Python package for each user:

 pip install --user [python-package-name] 

I used this option to install the package on a server for which I do not have root access. Now I need to remove the installed package for the current user. I tried to execute this command:

 pip uninstall --user [python-package-name] 

But I got:

 no such option: --user 

How to remove a package that I installed using pip install --user , besides manually finding and removing the package?

I found this article

pip cannot remove from the site sites directory for each user

which describes that removing packages from the user directory is not supported. According to the article, if it was done correctly, then using

 pip uninstall [package-name] 

the installed package will also run in user directories. But the problem still remains for me. What if the same package was installed both for the entire system and for each user? What if someone needs to target a specific user directory?

+161
python pip virtualenv
Oct 29 '15 at 11:27
source share
7 answers

Testing this with Python 3.5 and pip 7.1.2 on Linux, the situation looks like this:

  • pip install --user somepackage installs on $HOME/.local and removes it using pip uninstall somepackage .

  • This is true whether or not somepackage is also somepackage system-wide at the same time.

  • If the package is installed in both places, only the local one is removed. To uninstall a package throughout the system using pip , first uninstall it locally, then run the same uninstall command again, with root privileges.

  • In addition to the predefined user installation directory, pip install --target somedir somepackage will install the package in somedir . It is not possible to remove a package from such a location using pip . (But on Github there is a somewhat old unrelated tensile request that pip uninstall --target .)

  • Since the only pip locations are ever removed from the system and predefined local-local user, you need to run pip uninstall as the appropriate user to remove the local user from the local installation directory.

+146
Feb 20 '16 at 14:20
source share

example of removing the package "oauth2client" on macOS:

 pip uninstall oauth2client 
+24
Mar 06 '17 at 13:16
source share

Answer Impossible yet . You must delete it manually.

+2
Feb 20 '16 at 15:32
source share

As @ thomas-lotze mentioned, pip tools do not currently do this because there is no corresponding --user option. But I found that I can check in ~ / .local / bin and find the specific item #. # Which, it seems to me, matches the --user option.

In my case:

 antho@noctil: ~/.l/bin$ pwd /home/antho/.local/bin antho@noctil: ~/.l/bin$ ls pip* pip pip2 pip2.7 pip3 pip3.5 

And then just uninstall with a specific pip version.

+2
Aug 17 '17 at 20:15
source share

I am using Anaconda version 4.3.22 and python3.6.1 environment and I am having this problem. Here is the story and the fix:

 pip uninstall opencv-python # -- the original step. failed. ImportError: DLL load failed: The specified module could not be found. 

I did this in my python3.6 environment and got this error.

 python -m pip install opencv-python # same package as above. conda install -c conda-forge opencv # separate install parallel to opencv pip-install opencv-contrib-python # suggested by another user here. doesn't resolve it. 

Then I tried to download python3.6 and put python3.dll in a folder and in different folders. Nothing changed.

finally this fixed:

 pip uninstall opencv-python 

(another version of conda-forge is still installed) This left only the conda version, and it works in 3.6.

 >>>import cv2 >>> 

at work!

0
Sep 14 '18 at 1:24
source share

Be careful with those using pip install --user some_pkg in a virtual environment .

 $ path/to/python -m venv ~/my_py_venv $ source ~/my_py_venv/bin/activate (my_py_venv) $ pip install --user some_pkg (my_py_venv) $ pip uninstall some_pkg WARNING: Skipping some_pkg as it is not installed. (my_py_venv) $ pip list # Even 'pip list' will not properly list the 'some_pkg' in this case 

In this case, you need to deactivate the current virtual environment , and then use the appropriate python / pip executable to list or remove user site packages:

 (my_py_venv) $ deactivate $ path/to/python -m pip list $ path/to/python -m pip uninstall some_pkg 

Please note that this problem was reported several years ago . And, it seems that the current output is: --user does not work in the virtual okr pip , since the user's location does not make sense for the virtual environment.

0
Jul 09 '19 at 8:26
source share

You can remove all packages at once.

 1. First, install pip-purge. pip install pip-purge 2. Then, Run pip-purge 

Make sure to just run at virtualenv

-one
Jan 12 '19 at 18:38
source share



All Articles