Python的easy_install使得安装新包极其方便。然而,据我所知,它没有实现依赖管理器的其他常见特性——列出和删除已安装的包。

找出已安装包的最佳方法是什么,以及删除已安装包的首选方法是什么?如果我手动删除包(例如rm /usr/local/lib/python2.6/dist-packages/my_installed_pkg),是否有任何文件需要更新。鸡蛋或类似的)?


当前回答

官方(?)说明:http://peak.telecommunity.com/DevCenter/EasyInstall#uninstalling-packages

If you have replaced a package with another version, then you can just delete the package(s) you don't need by deleting the PackageName-versioninfo.egg file or directory (found in the installation directory). If you want to delete the currently installed version of a package (or all versions of a package), you should first run: easy_install -mxN PackageName This will ensure that Python doesn't continue to search for a package you're planning to remove. After you've done this, you can safely delete the .egg files or directories, along with any scripts you wish to remove.

其他回答

If the problem is a serious-enough annoyance to you, you might consider virtualenv. It allows you to create an environment that encapsulates python libraries. You install packages there rather than in the global site-packages directory. Any scripts you run in that environment have access to those packages (and optionally, your global ones as well). I use this a lot when evaluating packages that I am not sure I want/need to install globally. If you decide you don't need the package, it's easy enough to just blow that virtual environment away. It's pretty easy to use. Make a new env:

$>virtualenv /path/to/your/new/ENV

Virtual_envt在新环境中为你安装setuptools,所以你可以这样做:

$>ENV/bin/easy_install

您甚至可以创建自己的boostrap脚本来设置新环境。因此,用一个命令,你就可以创建一个新的虚拟env,比如python 2.6, psycopg2和默认安装的django(如果你愿意,你也可以安装env特定版本的python)。

我在MacOS X Leopard 10.6上也遇到了同样的问题。

解决方案是确保你正在调用MacPorts Python:

sudo port install python26
sudo port install python_select
sudo python_select python26
sudo port install py26-mysql

希望这能有所帮助。

官方(?)说明:http://peak.telecommunity.com/DevCenter/EasyInstall#uninstalling-packages

If you have replaced a package with another version, then you can just delete the package(s) you don't need by deleting the PackageName-versioninfo.egg file or directory (found in the installation directory). If you want to delete the currently installed version of a package (or all versions of a package), you should first run: easy_install -mxN PackageName This will ensure that Python doesn't continue to search for a package you're planning to remove. After you've done this, you can safely delete the .egg files or directories, along with any scripts you wish to remove.

try

$ easy_install -m [PACKAGE]

then

$ rm -rf .../python2.X/site-packages/[PACKAGE].egg

在尝试卸载随时间安装的许多随机Python包时遇到了这个问题。

利用这篇文章中的信息,我得出了以下结论:

cat package_list | xargs -n1 sudo pip uninstall -y

从virtualenv中的pip冻结中清理package_list (awk)。

删除几乎所有Python包:

yolk -l | cut -f 1 -d " " | grep -v "setuptools|pip|ETC.." | xargs -n1 pip uninstall -y