There is a --user
option for pip which can install a Python package per user:
pip install --user [python-package-name]
I used this option to install a package on a server for which I do not have root access. What I need now is to uninstall the installed package on the current user. I tried to execute this command:
pip uninstall --user [python-package-name]
But I got:
no such option: --user
How can I uninstall a package that I installed with pip install --user
, other than manually finding and deleting the package?
I've found this article
pip cannot uninstall from per-user site-packages directory
which describes that uninstalling packages from user directory does not supported. According to the article if it was implemented correctly then with
pip uninstall [package-name]
the package that was installed will be also searched in user directories. But a problem still remains for me. What if the same package was installed both system-wide and per-user?
What if someone needs to target a specific user directory?
Having tested this using Python 3.5 and pip 7.1.2 on Linux, the situation appears to be this:
pip install --user somepackage
installs to $HOME/.local
, and uninstalling it does work using pip uninstall somepackage
.
This is true whether or not somepackage
is also installed system-wide at the same time.
If the package is installed at both places, only the local one will be uninstalled. 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
. There is no way to uninstall a package from such a place using pip
. (But there is a somewhat old unmerged pull request on Github that implements pip uninstall --target
.)
Since the only places pip
will ever uninstall from are system-wide and predefined user-local, you need to run pip uninstall
as the respective user to uninstall from a given user's local install directory.
example to uninstall package 'oauth2client' on MacOS:
pip uninstall oauth2client
The answer is Not possible yet. You have to remove it manually.
As @thomas-lotze has mentioned, currently pip tooling does not do that as there is no corresponding --user option. But what I find is that I can check in ~/.local/bin and look for the specific pip#.# which looks to me like it corresponds to 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 the specific pip version.
I am running Anaconda version 4.3.22 and a python3.6.1 environment, and had this problem. Here's the history 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 into 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.
Next, I tried downloading python3.6 and putting the python3.dll in the folder and in various folders. nothing changed.
finally, this fixed it:
pip uninstall opencv-python
(the other conda-forge version is still installed) This left only the conda version, and that works in 3.6.
>>>import cv2
>>>
working!