python using easy_install ImportError: No module named _md5

六月ゝ 毕业季﹏ 提交于 2019-12-01 12:34:51

问题


I searched a lot and did not find any answer to this problem =(

I have a CentOS 5 as a server, following this How To: http://wiki.osqa.net/display/docs/RHEL%2C+CentOS+5+Installation+Guide#RHEL%2CCentOS5InstallationGuide-Python

I'm able to install python 2.6 separated from the yum version. But when I run ./easy_install ElementTree I get this strange error:

    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

I do not understand python and have no idea how to fix this issue, I'm trying to install OSQA to run a phpBB support forum for another country.

Thanks for any help, best regard's.


回答1:


My guess having had a similar issue on CentOS before, is that the ld path for the new Python isn't set, and it can't find its loadable modules folder.

The 3rd code block on this blog post shows setting an ld path for an opt Python (though it is 2.7): http://toey.tc20.net/2010/08/04/install-python-2-7-gevent-on-centos-5-x86_64/

I would assume that an installer would have done this as part of the install step, but maybe the blog post above will be of some help.




回答2:


I had the same problem and found that the issue is unrelated to _md5.so, but instead that hashlib is failing to import _hashlib.so within a try block, then getting to a different and normally unused section of code (where the _md5 problem shows up). Try:

import _hashlib.so

I got something like:

ImportError: <PATH>/lib/python2.7/lib-dynload/_hashlib.so: cannot restore segment prot after reloc: Permission denied

I googled that and found http://www.quantumwise.com/forum/index.php?topic=16.0 which says you need to do:

chcon -t texrel_shlib_t <PATH>/lib/python2.7/lib-dynload/_hashlib.so

This worked for me.




回答3:


Activepython 2.6 seems to have some problem in their latest build. please check for its former release.




回答4:


I also encounter the same issue like you, I fix it after I add the lib path of python where the module will be installed.

It is really caused by LD_LIBRARY_PATH, please try to add "/opt/ActivePython-2.6/lib" into your LD_LIBRARY_PATH.

setenv LD_LIBRARY_PATH /opt/ActivePython-2.6/lib:$LD_LIBRARY_PATH



回答5:


Credit to http://johnsofteng.wordpress.com/2009/06/21/python-importerror-no-module-named-_md5/

I met the similar problem on Redhat 6.4, python binary (2.7.x) packages is copied from other already installed system (which is built from source).

The problem is the _hashlib.so, which miss the libssl.so.0.9.8

bash-4.1# ldd /proj/application/tools/python2.7/lib/python2.7/lib-dynload/_hashlib.so
    linux-vdso.so.1 =>  (0x00007fff51d6f000)
    libssl.so.0.9.8 => not found
    libcrypto.so.0.9.8 => /usr/lib64/libcrypto.so.0.9.8 (0x00007f9a69746000)
    libpython2.7.so.1.0 => /proj/application/tools/python2.7/lib/libpython2.7.so.1.0 (0x00007f9a6936b000)

I just install missed package and soft link to the library.

bash-4.1# yum install -y tar openssh-clients
bash-4.1# ln -s /usr/lib64/libssl.so.0.9.8e /usr/lib64/libssl.so.0.9.8

Then the setuptool installation is successful



来源:https://stackoverflow.com/questions/4278874/python-using-easy-install-importerror-no-module-named-md5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!