简体   繁体   English

Python 2.6 virtualenv,pip抛出“ ImportError:没有名为_md5的模块”

[英]Python 2.6 virtualenv, pip throwing “ImportError: No module named _md5”

I've been developing a django site (irrelevant) under python 2.5 up until now, when I wanted to switch to python 2.6 to make sure things worked there. 到目前为止,我一直在python 2.5下开发django站点(无关),当时我想切换到python 2.6以确保一切正常。 However, when I was setting up my virtualenv for 2.6, pip threw an error "ImportError: No module named _md5". 但是,当我为2.6设置virtualenv时,pip抛出错误“ ImportError:No module named _md5”。

Background: 背景:

  • I'm running on Ubuntu Maverick 10.10. 我在Ubuntu Maverick 10.10上运行。
  • My python 2.5 was coming from fkrull's deadsnakes repo , and has been working without issues. 我的python 2.5来自fkrull的deadsnakes repo ,并且一直在正常工作。
  • I create virtualenvs with virtualenv <path> --no-site-packages --python=python2.[56] 我用virtualenv <path> --no-site-packages --python=python2.[56]创建virtualenvs virtualenv <path> --no-site-packages --python=python2.[56]

If I try to import hashlib from outside a virtualenv, it works fine: 如果我尝试从virtualenv外部导入hashlib,则可以正常工作:

$ python2.6
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import hashlib
>>>

But inside it throws the same ImportError. 但是在里面抛出相同的ImportError。

I've tried reinstalling python2.6, libpython2.6, and python2.6-minimal and recreating my virtualenv, but I get the same error. 我尝试过重新安装python2.6,libpython2.6和python2.6-minimal并重新创建我的virtualenv,但是我遇到了同样的错误。

None of the list of potential duplicates didn't help, as they either use different linux distros or simply say "recompile python". 可能的重复项列表都无济于事,因为它们要么使用不同的Linux发行版,要么干脆说“重新编译python”。

Ideas? 想法?

The problem ended up being different versions of python2.6 -- my virtualenv (which I had actually created at an earlier date to the same purpose) already had python 2.6.4 installed, while the system was up to 2.6.6. 问题最终是不同版本的python2.6-我的virtualenv(我实际上是出于相同的目的在较早的日期创建的)已经安装了python 2.6.4,而系统的最高版本是2.6.6。

I had tried virtualenv <path> --no-site-packages --python=python2.6 --clear , but apparently --clear doesn't clear out the old python bin. 我试过virtualenv <path> --no-site-packages --python=python2.6 --clear ,但显然--clear不能清除旧的python bin。

rm -rf -ing the env directory and recreating it from scratch (so the venv had 2.6.6 as well) fixed the issue. rm -rf -rf-进入env目录并从头开始重新创建它(因此venv也具有2.6.6)解决了该问题。

I had similar problem. 我有类似的问题。 I used virtualenv checked out from external repository. 我使用virtualenv从外部存储库中签出。 Inside virtualenv I had 32-bit python2.6.4 and inside my local system I had 64-bit python 2.6.6. 在virtualenv内部,我有32位python2.6.4,在本地系统内部,我有64位python 2.6.6。 When I typed 当我输入

>>> import hashlib

inside my virtualenv I received the same exception ( ImportError: No module named _md5 ). 在我的virtualenv内部,我收到了相同的异常( ImportError: No module named _md5 )。 The real problem was with importing _hashlib module. 真正的问题是导入_hashlib模块。 It threw an exception ImportError: libssl.so.0.9.8: wrong ELF class: ELFCLASS64 . 它引发了异常ImportError: libssl.so.0.9.8: wrong ELF class: ELFCLASS64 The solution was to install ia32-libs package. 解决方案是安装ia32-libs软件包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM