Python的easy_install使得安装新包极其方便。然而,据我所知,它没有实现依赖管理器的其他常见特性——列出和删除已安装的包。
找出已安装包的最佳方法是什么,以及删除已安装包的首选方法是什么?如果我手动删除包(例如rm /usr/local/lib/python2.6/dist-packages/my_installed_pkg),是否有任何文件需要更新。鸡蛋或类似的)?
Python的easy_install使得安装新包极其方便。然而,据我所知,它没有实现依赖管理器的其他常见特性——列出和删除已安装的包。
找出已安装包的最佳方法是什么,以及删除已安装包的首选方法是什么?如果我手动删除包(例如rm /usr/local/lib/python2.6/dist-packages/my_installed_pkg),是否有任何文件需要更新。鸡蛋或类似的)?
当前回答
这对我很管用。它与前面的答案相似,但是包的路径不同。
Sudo easy_install -m sudo rm -rf /Library/Python/2.7/site-packages/.egg
平台:MacOS High Sierra 10.13.3版本
其他回答
在尝试卸载随时间安装的许多随机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
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)。
网上有几个来源建议使用-m选项重新安装包,然后删除lib/中的.egg文件和bin/中的二进制文件。此外,关于此setuptools问题的讨论可以在python错误跟踪器中作为setuptools问题21找到。
编辑:添加了python bug跟踪器的链接。
官方(?)说明: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.
我只删除这个文件:easy-install.pth 工作,休息PIP安装django==1.3.7