How to Uninstall a Package Installed with Pip Install --User

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

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.

Uninstall a package installed with `pip install .`

Simply run pip uninstall package-name

That's all you need.

For more follow this link : https://pip.pypa.io/en/stable/reference/pip_uninstall/

is there an uninstall equivalent to pip install --user package?

This was a known bug in pip

Ref : https://github.com/pypa/pip/issues/2094

As pip uninstall does not have --user option unlike pip install the question is if there even exists a way to uninstall package installed with pip install --user?

It is now cleared with a note

The packages mentioned in the ticket started working after they offered Wheel-based packages.

pip install package with --user and without --user, now I want to uninstall package installed without --user

I tried

pip uninstall virtualenv

It removed /usr/local/bin/virtualenv, the system wide package.

The package I installed using --user flag, which cannot be uninstalled.

I just manually removed the folder.

See this thread.

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

pip how to remove incorrectly installed package with a leading dash: -pkgname

EDIT: According to this link, provided by Lawrence in his answer

looking for and deleting the incorrectly named folders in your site-package directory should solve the issue.

If this is not sufficient, continue the cleaning as explained below.

Searching for the name of the broken package (without the leading dash) allowed me to find the following two folders:

C:\Users\name\Anaconda3\Lib\site-packages~atplotlib

C:\Users\name\Anaconda3\Lib\site-packages~atplotlib-3.0.3-py3.7.egg-info

Following Hoefling's comment (below)

I checked the SOURCES.txt file in the egg-info directory %dir%/~atplotlib-3.0.3-py3.7.egg-info/SOURCES.txt. Went through the list of paths in this file and made sure all paths listed did not contained ~. Then I renamed the directory ~atplotlib-3.0.3-py3.7.egg-info into atplotlib-3.0.3-py3.7.egg-info (removed the tilde ~).

Finally, I ran pip uninstall atplotlib, which prompted the following:

Uninstalling atplotlib-3.0.3:

Would remove:

C:\Users\name\Anaconda3\Lib\site-packages\atplotlib-3.0.3-py3.7.egg-info
C:\Users\name\Anaconda3\Lib\site-packages\matplotlib

C:\Users\name\Anaconda3\Lib\site-packages\pylab.py

Proceeding with the removal solved the issue (the warning disappeared and the package is not anymore on the package list.

What is the easiest way to remove all packages installed by pip?

I've found this snippet as an alternative solution. It's a more graceful removal of libraries than remaking the virtualenv:

pip freeze | xargs pip uninstall -y

In case you have packages installed via VCS, you need to exclude those lines and remove the packages manually (elevated from the comments below):

pip freeze | grep -v "^-e" | xargs pip uninstall -y

If you have packages installed directly from github/gitlab, those will have @.
Like:

django @ git+https://github.com/django.git@<sha>

You can add cut -d "@" -f1 to get just the package name that is required to uninstall it.

pip freeze | cut -d "@" -f1 | xargs pip uninstall -y

How do I remove all packages installed by PIP?

The following command should do the trick:

pip freeze > requirements.txt && pip uninstall -r requirements.txt -y

Alternatively you can skip the creation of any intermediate files (i.e. requirements.txt):

pip uninstall -y -r <(pip freeze)

How to uninstall editable packages with pip (installed with -e)

At {virtualenv}/lib/python2.7/site-packages/ (if not using virtualenv then {system_dir}/lib/python2.7/dist-packages/)

  • remove the egg file (e.g. distribute-0.6.34-py2.7.egg) if there is any
  • from file easy-install.pth, remove the corresponding line (it should be a path to the source directory or of an egg file).

Calling `pip uninstall` from the source folder where `setup.py install` was called

In the output of the pip show -f pybliometrics command, we can read:

Files:
Cannot locate RECORD or installed-files.txt

This might explain why it can not be uninstalled. And I am not sure how this happened, nor how to fix it.

But with that said, here are some notes:

  1. The commands shown in your question are inconsistent. On one hand you call pip show -f pybliometrics and on the other you call pip3 uninstall pybliometrics. But pip and pip3 are not necessarily the same thing, and do not necessarily interact with the same projects.

  2. Do not use python setup.py install. Calling the setup.py is now deprecated, the recommended way of installing a Python project is via pip.

  3. One should never call the pip scripts directly, but should always prefer explicitly calling the pip executable module with the targeted Python interpreter (see this reference article and this other answer for details).

So in your case what you probably should have done (no guarantee it would have solved your issue, but it would have minimized risks):

  • Clearly identify which Python interpreter you want to use, let's say it is path/to/bin/pythonX.Y
  • Install project with: path/to/bin/pythonX.Y -m pip install --user path/to/pybliometrics
  • Check installed project with path/to/bin/pythonX.Y -m pip show -f pybliometrics
  • Uninstall project with: path/to/bin/pythonX.Y -m pip uninstall pybliometrics


Related Topics



Leave a reply



Submit