python virtualenv - 缺少一些 python 核心库

发布于 2024-11-30 02:00:19 字数 2971 浏览 1 评论 0原文

我正在尝试在 CentOS 5 上使用 Python 2.6.6 设置 virtualenv。 我已经在我的主目录中安装了 Python 2.6.6,运行良好。

但是,当我尝试设置 virtualenv 时,出现以下错误(参见完整日志的 end):

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

I'm trying to set-up a virtualenv with Python 2.6.6 on CentOS 5.
I've already Python 2.6.6 installed in my home directory, working well.

However, when I try to set-up a virtualenv, I got the following error (cf. end for full log):

ImportError: No module named _md5

By looking at other threads, this errors occurs when changing python version on existing virtual env, which is not my case: I trying to create a new one.

Because this error occurs when installing setuptools, I juste commented few lines in virtualenv.py source (around l.907), so it's just installing Python.
Then, creation of virtualenv is fine, however, many core Python libraries are missing.

# 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

I really don't get the point! Python libraries are just files to copy, right?


Full log:

$ 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

在梵高的星空下 2024-12-07 02:00:20

AFAIK _md5 依赖于一些 openssl 软件包。您应该先安装它们。

您可能还会发现此线程很有用。

AFAIK _md5 depends on some openssl packages. You should install them first.

You may also find this thread useful.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文