今天在一些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就不可用了,遇到的错误如下:
1 2 3 4 5 6 7 8 9 |
jay@jay-linux:~$ sudo easy_install MySQL-python Traceback (most recent call last): File "/usr/local/bin/easy_install", line 9, in <module> 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:
1 2 |
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:
1 2 3 |
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.:
1 2 |
jay@jay-linux:~$ sudo easy_install pip jay@jay-linux:~$ sudo easy_install MySQL-python |
http://stackoverflow.com/questions/6012246/why-is-python-easy-install-not-working-on-my-mac
http://pythonhosted.org/distribute/
http://pythonhosted.org/distribute/
http://python-distribute.org/distribute_setup.py
已经无法打开,翻墙也不行.
哦 我写博客是还正常的。 你可以直接下载:http://pypi.python.org/packages/source/d/distribute/distribute-0.6.49.tar.gz
里面也有distribute_setup.py文件,另外,你还可用setup.py来安装,参考如下:
https://pypi.python.org/pypi/distribute/0.6.49