python使用easy_install时ImportError: 未找到模块_md5
我搜索了很多,但没有找到这个问题的答案 =(
我有一台 CentOS 5 的服务器,按照这个教程来操作:http://wiki.osqa.net/display/docs/RHEL%2C+CentOS+5+Installation+Guide#RHEL%2CCentOS5InstallationGuide-Python
我能够把 python 2.6 安装在和 yum 版本分开的地方。但是当我运行 ./easy_install ElementTree 时,出现了一个奇怪的错误:
Traceback (most recent call last):
File "./easy_install", line 9, in <module>
load_entry_point('distribute==0.6.14', 'console_scripts', 'easy_install')()
File "/opt/ActivePython-2.6/lib/python2.6/site-packages/pkg_resources.py", line 305, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/opt/ActivePython-2.6/lib/python2.6/site-packages/pkg_resources.py", line 2244, in load_entry_point
return ep.load()
File "/opt/ActivePython-2.6/lib/python2.6/site-packages/pkg_resources.py", line 1954, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/opt/ActivePython-2.6/lib/python2.6/site-packages/setuptools/command/easy_install.py", line 24, in <module>
from setuptools.package_index import PackageIndex
File "/opt/ActivePython-2.6/lib/python2.6/site-packages/setuptools/package_index.py", line 2, in <module>
import sys, os.path, re, urlparse, urllib2, shutil, random, socket, cStringIO
File "/opt/ActivePython-2.6/lib/python2.6/urllib2.py", line 93, in <module>
import hashlib
File "/opt/ActivePython-2.6/lib/python2.6/hashlib.py", line 136, in <module>
md5 = __get_builtin_constructor('md5')
File "/opt/ActivePython-2.6/lib/python2.6/hashlib.py", line 63, in __get_builtin_constructor
import _md5
ImportError: No module named _md5
我对 python 不太了解,也不知道该怎么解决这个问题。我正在尝试安装 OSQA,以便为另一个国家运行一个 phpBB 支持论坛。
谢谢任何帮助,祝好。
5 个回答
最新版本的Activepython 2.6好像有一些问题。建议你查看一下之前的版本。
我也遇到过同样的问题,发现这个问题其实和_md5.so没有关系。真正的问题是,hashlib在一个尝试导入的过程中,无法导入_hashlib.so,然后就跳到了另一段通常不会用到的代码里(这时候就出现了_md5的问题)。你可以试试:
import _hashlib.so
我得到了类似这样的结果:
ImportError: <PATH>/lib/python2.7/lib-dynload/_hashlib.so: cannot restore segment prot after reloc: Permission denied
我在网上搜索了一下,发现了这个链接 http://www.quantumwise.com/forum/index.php?topic=16.0,上面说你需要做:
chcon -t texrel_shlib_t <PATH>/lib/python2.7/lib-dynload/_hashlib.so
这个方法对我有效。
我猜之前在CentOS上遇到过类似的问题,可能是新安装的Python没有设置ld路径,所以找不到它的可加载模块文件夹。
这篇博客的第三个代码块展示了如何为一个opt Python设置ld路径(虽然是2.7版):http://toey.tc20.net/2010/08/04/install-python-2-7-gevent-on-centos-5-x86_64/
我本以为安装程序会在安装步骤中自动完成这个设置,但也许上面的博客会对你有所帮助。