关于卸载:如何使用pip卸载可编辑软件包(与-e一起安装)

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

我已经用-e安装了一些软件包

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

我用点子冻结我明白了

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

当我尝试卸载软件包时,出现错误:

1
2
3
4
5
> pip uninstall horus-dev
Cannot uninstall requirement horus-dev, not installed

> pip uninstall horus
Cannot uninstall requirement horus, not installed

如何卸载这样的软件包?


{virtualenv}/lib/python2.7/site-packages/处(如果未使用virtualenv,则在{system_dir}/lib/python2.7/dist-packages/处)

  • 删除鸡蛋文件(例如distribute-0.6.34-py2.7.egg)(如果有)
  • 从文件easy-install.pth中删除相应的行(它应该是源目录的路径或egg文件的路径)。


使用新版本的setup_tools进行此操作的更简单方法是运行以下命令:

1
python setup.py develop -u

基本上与@glarrain在其答案中描述的功能相同。


使用cmd安装开发包:

1
pip install --editable .

卸载:

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

现在您可以使用:

1
pip uninstall package_name

python setup.py develop --uninstallpython setup.py develop -u


这是使用操作系统安装的pip(对我而言是v8.1.1)在debian / ubuntu linux上的错误,即使升级了pip(例如,get-pip.py),也要使用sudo pip调用它。参见https://github.com/pypa/pip/issues/4438

有关如何清理的讨论,请参见https://askubuntu.com/questions/173323/how-do-i-detect-and-remove-python-packages-installed-via-pip,尽管其中有解决方案"删除所有内容"种类繁多。

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

对于我的系统,我需要删除的是/usr/local/lib/python2.7/dist-packages/{package_name}.egg-link


原来,我的安装已损坏。

我可以在以下位置找到条目:

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

为了解决该问题,我手动删除了.pth文件中的行!

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


只需卸载以"可编辑"模式安装的软件包:

1
pip uninstall yourpackage