开发者

Python 2.6 virtualenv, pip throwing "ImportError: No module named _md5"

开发者 https://www.devze.com 2023-02-21 00:09 出处:网络
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.However, when I was setting up my virtualenv for

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. However, when I was setting up my virtualenv for 2.6, pip threw an error "ImportError: No module named _md5".

Background:

  • I'm running on Ubuntu Maverick 10.10.
  • My python 2.5 was coming from fkrull's deadsnakes repo, and has been working without issues.
  • I create virtualenvs with virtualenv <path> --no-site-packages --python=python2.[56]

If I try to import hashlib from outside a virtualenv, it works fine:

$ 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.

I've tried reinstalling python2.6, libpython2.6, and python2.6-minimal and recreating my virtualenv, but I get the same error.

None of the list of potential duplicates didn't help, as they either use different linux distros or simply say开发者_开发问答 "recompile 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.

I had tried virtualenv <path> --no-site-packages --python=python2.6 --clear, but apparently --clear doesn't clear out the old 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.


I had similar problem. I used virtualenv checked out from external repository. Inside virtualenv I had 32-bit python2.6.4 and inside my local system I had 64-bit python 2.6.6. When I typed

>>> import hashlib

inside my virtualenv I received the same exception (ImportError: No module named _md5). The real problem was with importing _hashlib module. It threw an exception ImportError: libssl.so.0.9.8: wrong ELF class: ELFCLASS64. The solution was to install ia32-libs package.

0

精彩评论

暂无评论...
验证码 换一张
取 消