我正在尝试在CentOS 5上使用Python 2.6.6设置virtualenv。 我已经在我的主目录中安装了Python 2.6.6,运行良好。
然而,当我尝试设置virtualenv时,我收到以下错误(cf. end for full log):
ImportError: No module named _md5
通过查看其他线程,在现有虚拟环境中更改python版本时会出现此错误,这不是我的情况:我尝试创建一个新版本。
因为在安装setuptools时会出现这个错误,所以我在virtualenv.py源代码中注释了几行(大约l.907),所以它只是安装Python。 然后,virtualenv的创建很好,但是,缺少许多核心Python库。
# Creating virtualenv
$ pwd
/home/myhome/tmp/virtualenv-1.6.4
$ python virtualenv.py --no-site-packages myenv
New python executable in myenv/bin/python
# Loading module outside virtualenv
$ python -c 'import time'
# Loading module inside virtualenv
$ source ve/bin/activate
$ python -c 'import time'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named time
我真的不明白这一点! Python库只是要复制的文件,对吧?
完整日志:
$ virtualenv --no-site-packages myenv
New python executable in myenv/bin/python2.6
Also creating executable in myenv/bin/python
Installing setuptools.............
Complete output from command /home/myhome/myenv/bin/python2.6 -c "#!python
\"\"\"Bootstra...sys.argv[1:])
" --always-copy -U setuptools:
-c:67: DeprecationWarning: the md5 module is deprecated; use hashlib instead
Traceback (most recent call last):
File "<string>", line 67, in <module>
File "/home/myhome/lib/python2.6/md5.py", line 10, in <module>
from hashlib import md5
File "/home/myhome/lib/python2.6/hashlib.py", line 136, in <module>
md5 = __get_builtin_constructor('md5')
File "/home/myhome/lib/python2.6/hashlib.py", line 63, in __get_builtin_constructor
import _md5
ImportError: No module named _md5
----------------------------------------
...Installing setuptools...done.
Traceback (most recent call last):
File "/home/myhome/bin/virtualenv", line 8, in <module>
load_entry_point('virtualenv==1.6.4', 'console_scripts', 'virtualenv')()
File "/home/myhome/lib/python2.6/site-packages/virtualenv-1.6.4-py2.6.egg /virtualenv.py", line 810, in main
never_download=options.never_download)
File "/home/myhome/lib/python2.6/site-packages/virtualenv-1.6.4-py2.6.egg/virtualenv.py", line 910, in create_environment
search_dirs=search_dirs, never_download=never_download)
File "/home/myhome/lib/python2.6/site-packages/virtualenv-1.6.4-py2.6.egg/virtualenv.py", line 603, in install_setuptools
search_dirs=search_dirs, never_download=never_download)
File "/home/myhome/lib/python2.6/site-packages/virtualenv-1.6.4-py2.6.egg/virtualenv.py", line 577, in _install_req
cwd=cwd)
File "/home/myhome/lib/python2.6/site-packages/virtualenv-1.6.4-py2.6.egg/virtualenv.py", line 878, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /home/myhome/myenv/bin/python2.6 -c "#!python
\"\"\"Bootstra...sys.argv[1:])
" --always-copy -U setuptools failed with error code 1