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

孤街醉人 提交于 2019-11-27 04:02:30

问题


I have installed some packages with -e

> pip install -e git+https://github.com/eventray/horus.git@2ce62c802ef5237be1c6b1a91dbf115ec284a619#egg=horus-dev

I with pip freeze I see

> pip freeze
...
-e git+https://github.com/eventray/horus.git@2ce62c802ef5237be1c6b1a91dbf115ec284a619#egg=horus-dev
...

when I try to uninstall the packages I get errors:

> pip uninstall horus-dev
Cannot uninstall requirement horus-dev, not installed

> pip uninstall horus
Cannot uninstall requirement horus, not installed

How do I uninstall such a package?


回答1:


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).



回答2:


Install a dev package use cmd:

pip install --editable .

Uninstall:

rm -r $(find . -name '*.egg-info')



回答3:


An easier way to do the same with the new version of setup_tools is to run the following:

python setup.py develop -u

Which basically does the same as what @glarrain describes in his answer.




回答4:


This is a bug on debian/ubuntu linux using OS-installed pip (v8.1.1 for me), which is what you'll invoke with sudo pip even if you've upgraded pip (e.g. get-pip.py). See https://github.com/pypa/pip/issues/4438

For a discussion on how to clean up see https://askubuntu.com/questions/173323/how-do-i-detect-and-remove-python-packages-installed-via-pip, though the solutions there are of the "remove everything" variety.

...pip packages [go] to /usr/local/lib/python2.7/dist-packages, and apt packages to /usr/lib/python2.7/dist-packages

...a few packages were installed in ~/.local/lib too.

For my system all I needed to remove was /usr/local/lib/python2.7/dist-packages/{package_name}.egg-link




回答5:


It turns out that my installation was somehow corrupt.

I could find the entry in:

/usr/local/lib/python2.7/site-packages/easy-install.pth

To solve the problem I removed the line in the .pth file by hand!

import sys; sys.__plen = len(sys.path)
...
/absolute-path-to/horus  # <- I removed this line
...



回答6:


In case it helps anyone else: Not sure if it's the same problem, but I faced something similar, where I had installed a package locally for development with:

$ pip install -e .

but when I ran

$ pip uninstall -e .

I got

Usage:   
  pip uninstall [options] <package> ...
  pip uninstall [options] -r <requirements file> ...

no such option: -e

and when I run pip freeze I get

package1=1.0.0
package2=1.0.0
...
package12=1.0.0
-e git+git@github.com/me/my-repo.git@hash
package13=1.0.0
...

So I dumped this to a requirements.txt, removed everything but the -e line(s) and then executed:

$ pip uninstall -r requirements.txt

which worked for me




回答7:


Simply uninstall the package you installed in 'editable' mode:

pip uninstall yourpackage


来源:https://stackoverflow.com/questions/17346619/how-to-uninstall-editable-packages-with-pip-installed-with-e

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!