问题:如何删除使用Python的easy_install安装的软件包?
Python easy_install
使安装新软件包非常方便。但是,据我所知,它没有实现依赖项管理器的其他常见功能-列出和删除已安装的软件包。
找出已安装的软件包的最佳方法是什么,以及删除已安装软件包的首选方法是什么?如果我手动(例如,通过rm /usr/local/lib/python2.6/dist-packages/my_installed_pkg.egg
类似方式)删除软件包,是否需要更新任何文件?
Python’s easy_install
makes installing new packages extremely convenient. However, as far as I can tell, it doesn’t implement the other common features of a dependency manager – listing and removing installed packages.
What is the best way of finding out what’s installed, and what is the preferred way of removing installed packages? Are there any files that need to be updated if I remove packages manually (e.g. by rm /usr/local/lib/python2.6/dist-packages/my_installed_pkg.egg
or similar)?
回答 0
pip是setuptools / easy_install的替代产品,提供了“卸载”命令。
根据安装说明安装pip :
$ wget https://bootstrap.pypa.io/get-pip.py
$ python get-pip.py
然后,您可以使用pip uninstall
删除与easy_install
pip, an alternative to setuptools/easy_install, provides an “uninstall” command.
Install pip according to the installation instructions:
$ wget https://bootstrap.pypa.io/get-pip.py
$ python get-pip.py
Then you can use pip uninstall
to remove packages installed with easy_install
回答 1
要卸载,.egg
您需要rm -rf
鸡蛋(可能是目录)并从中删除匹配的行site-packages/easy-install.pth
To uninstall an .egg
you need to rm -rf
the egg (it might be a directory) and remove the matching line from site-packages/easy-install.pth
回答 2
首先,您必须运行以下命令:
$ easy_install -m [PACKAGE]
它删除了程序包的所有依赖项。
然后删除该包装的鸡蛋文件:
$ sudo rm -rf /usr/local/lib/python2.X/site-packages/[PACKAGE].egg
First you have to run this command:
$ easy_install -m [PACKAGE]
It removes all dependencies of the package.
Then remove egg file of that package:
$ sudo rm -rf /usr/local/lib/python2.X/site-packages/[PACKAGE].egg
回答 3
所有的信息在其他的答案,但没有总结两者的请求,或者似乎使事情不必要的复杂性:
All the info is in the other answers, but none summarizes both your requests or seem to make things needlessly complex:
For your removal needs use:
pip uninstall <package>
(install using easy_install pip
)
For your ‘list installed packages’ needs either use:
pip freeze
Or:
yolk -l
which can output more package details.
(Install via easy_install yolk
or pip install yolk
)
回答 4
网上有多个消息源建议通过使用-m选项重新安装软件包,然后仅删除lib /中的.egg文件和bin /中的二进制文件来破解。另外,可以在python bug跟踪器上找到有关setuptools问题的讨论,名称为setuptools issue 21。
编辑:将链接添加到python bugtracker。
There are several sources on the net suggesting a hack by reinstalling the package with the -m option and then just removing the .egg file in lib/ and the binaries in bin/. Also, discussion about this setuptools issue can be found on the python bug tracker as setuptools issue 21.
Edit: Added the link to the python bugtracker.
回答 5
如果问题严重困扰您,您可以考虑使用virtualenv。它允许您创建一个封装python库的环境。您在此处而不是在全局site-packages目录中安装软件包。您在该环境中运行的所有脚本都可以访问这些程序包(也可以选择全局程序包)。在评估不确定/是否需要全局安装的软件包时,我经常使用此工具。如果您决定不需要该软件包,那么将虚拟环境吹走就很容易了。它很容易使用。制作一个新的环境:
$>virtualenv /path/to/your/new/ENV
virtual_envt在新环境中为您安装setuptools,因此您可以执行以下操作:
$>ENV/bin/easy_install
您甚至可以创建自己的boostrap脚本来设置新环境。因此,使用一个命令,您可以创建一个新的虚拟环境,例如默认安装了python 2.6,psycopg2和django(如果需要,您可以安装特定于环境的python版本)。
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 installs setuptools for you in the new environment, so you can do:
$>ENV/bin/easy_install
You can even create your own boostrap scripts that setup your new environment. So, with one command, you can create a new virtual env with, say, python 2.6, psycopg2 and django installed by default (you can can install an env-specific version of python if you want).
回答 6
Official(?) instructions: 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.
回答 7
尝试
$ easy_install -m [PACKAGE]
然后
$ rm -rf .../python2.X/site-packages/[PACKAGE].egg
try
$ easy_install -m [PACKAGE]
then
$ rm -rf .../python2.X/site-packages/[PACKAGE].egg
回答 8
要列出已安装的Python软件包,可以使用yolk -l
。不过,您需要先使用easy_install yolk
。
To list installed Python packages, you can use yolk -l
. You’ll need to use easy_install yolk
first though.
回答 9
在尝试卸载随时间推移而安装的许多随机Python软件包时遇到了这个问题。
使用此线程中的信息,这是我想到的:
cat package_list | xargs -n1 sudo pip uninstall -y
该package_list
从清理(AWK)pip freeze
中的virtualenv。
要删除几乎所有的Python软件包:
yolk -l | cut -f 1 -d " " | grep -v "setuptools|pip|ETC.." | xargs -n1 pip uninstall -y
Came across this question, while trying to uninstall the many random Python packages installed over time.
Using information from this thread, this is what I came up with:
cat package_list | xargs -n1 sudo pip uninstall -y
The package_list
is cleaned up (awk) from a pip freeze
in a virtualenv.
To remove almost all Python packages:
yolk -l | cut -f 1 -d " " | grep -v "setuptools|pip|ETC.." | xargs -n1 pip uninstall -y
回答 10
我在MacOS X Leopard 10.6.blah上遇到了同样的问题。
解决方案是确保您正在调用MacPorts Python:
sudo port install python26
sudo port install python_select
sudo python_select python26
sudo port install py26-mysql
希望这可以帮助。
I ran into the same problem on my MacOS X Leopard 10.6.blah.
Solution is to make sure you’re calling the MacPorts Python:
sudo port install python26
sudo port install python_select
sudo python_select python26
sudo port install py26-mysql
Hope this helps.
回答 11
对我而言,仅删除此文件:easy-install.pth有效,其余pip install django == 1.3.7
For me only deleting this file : easy-install.pth
worked, rest pip install django==1.3.7
回答 12
这对我有用。它与先前的答案相似,但打包的路径不同。
- 须藤easy_install -m
- 须藤rm -rf /Library/Python/2.7/site-packages/.egg
平台:MacOS High Sierra版本10.13.3
This worked for me. It’s similar to previous answers but the path to the packages is different.
- sudo easy_install -m
- sudo rm -rf /Library/Python/2.7/site-packages/.egg
Plaform: MacOS High Sierra version 10.13.3