Python easy_install使用时提示 Entry point (‘console_scripts’, ‘easy_install’) not found

作者:袖梨 2022-11-14

在一些Linux机器上用easy_install安装MySQLdb时,遇到的问题,使用web.py做几个RESTful API和几个网页,与MySQL交互是需要用MySQLdb这个Python库,当使用“sudo easy_install MySQL-python”命令安装MySQLdb时,提示“
Please install a more recent version first, using ‘easy_install -U distribute’.”,我就执行“sudo easy_install -U distribute”命令升级distribute。没想到,升级后easy_install就不可用了,遇到的错误如下:

代码如下 复制代码
jay@jay-linux:~$ sudo easy_install MySQL-python
Traceback (most recent call last):
File "/usr/local/bin/easy_install", line 9, in
load_entry_point('distribute', 'console_scripts', 'easy_install')()
File "/usr/local/lib/python2.7/dist-packages/setuptools-1.4.1-py2.7.egg/pkg_resources.py", line 357, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python2.7/dist-packages/setuptools-1.4.1-py2.7.egg/pkg_resources.py", line 2393, in load_entry_point
raise ImportError("Entry point %r not found" % ((group,name),))
ImportError: Entry point ('console_scripts', 'easy_install') not found



大约是distribute升级到0.7之后的版本,就和以前的easy_install不兼容了,因为distribute从0.7版本后就和setuptools合并在一起了,网上找了个很好用的解决办法(对CentOS、Ubuntu、Mac都适用),如下:

1. 删除easy_install命令相关的可执行文件

Check your /usr/bin and /usr/local/bin for easy_install installations and remove any old script:

代码如下 复制代码
jay@jay-linux:~$ sudo rm /usr/bin/easy_install*
jay@jay-linux:~$ sudo rm /usr/local/bin/easy_install*



2. 下载和安装distribute

Download and run distribute:

代码如下 复制代码
jay@jay-linux:~$ curl -O http://python-distribute.org/distribute_setup.py
jay@jay-linux:~$ sudo python distribute_setup.py
jay@jay-linux:~$ sudo rm distribute_setup.py



如果上面的distribute_setup.py不能下载成功,那么可以直接下载distribute源码包:https://pypi.python.org/packages/source/d/distribute/distribute-0.6.49.tar.gz
参考这个文档的安装过程,https://pypi.python.org/pypi/distribute/0.6.49

3. 重新执行easy_install,已经修复了。

Try again, and enjoy. E.g.:

代码如下 复制代码
jay@jay-linux:~$ sudo easy_install pip
jay@jay-linux:~$ sudo easy_install MySQL-python

相关文章

精彩推荐