How to uninstall editable packages with pip (insta

2019-01-21 06:43发布

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?

标签: pip uninstall
6条回答
ゆ 、 Hurt°
2楼-- · 2019-01-21 06:49

Install a dev package use cmd:

pip install --editable .

Uninstall:

rm -r $(find . -name '*.egg-info')
查看更多
做自己的国王
3楼-- · 2019-01-21 06:54

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
...
查看更多
我只想做你的唯一
4楼-- · 2019-01-21 07:01

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

查看更多
冷血范
5楼-- · 2019-01-21 07:03

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

查看更多
地球回转人心会变
6楼-- · 2019-01-21 07:07

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

pip uninstall yourpackage
查看更多
戒情不戒烟
7楼-- · 2019-01-21 07:08

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).
查看更多
登录 后发表回答