Python Virtualenv:在ubuntu 10.04上创建python2.5环境
当我尝试创建使用 python2.5 的 virtualenv 时,出现以下错误:
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 1489, in <module>main()
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 526, in main use_distribute=options.use_distribute)
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 609, in create_environment
site_packages=site_packages, clear=clear))
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 672, in install_python fix_lib64(lib_dir)
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 891, in fix_lib64
if [p for p in distutils.sysconfig.get_config_vars().values()
File "/usr/lib/python2.5/distutils/sysconfig.py", line 499, in get_config_vars func()
File "/usr/lib/python2.5/distutils/sysconfig.py", line 351, in _init_posix filename = get_makefile_filename()
File "/usr/lib/python2.5/distutils/sysconfig.py", line 210, in get_makefile_filename
return os.path.join(lib_dir, "config" + (sys.pydebug and "_d" or ""), "Makefile")
AttributeError: 'module' object has no attribute 'pydebug'
我通过执行以下命令收到此错误:
virtualenv -p python2.5 .
因为 Ubuntu10.04 不附带 Python2.5,所以我从以下位置安装了它: 首先
我想我也应该为Python2.5安装virtualenv,但这似乎也不起作用。如果我尝试使用以下命令创建 virtualenv:
sudo Python2.5 /usr/lib/python2.5/site-packages/virtualenv.py .
我最终会收到相同的错误。我对 Ubuntu 和 Python 还比较陌生,还有一些空白。就像如果你有两个版本的Python,对于Python2.6我可以只做 virtualenv 。但我想要使用 2.5 版本,我必须直接调用它,就像我在上面的 sudo 命令中所做的那样?
或者这是完全错误的,所有 virtualenv 都是相同的并且可以与不同的 Python 版本一起使用?
无论如何,我的主要问题是如何修复错误,以便我可以使用 Python2.5 设置 virtualenv。如有任何额外信息,我们将不胜感激。
when I try to create a virtualenv that uses python2.5 I get the following error:
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 1489, in <module>main()
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 526, in main use_distribute=options.use_distribute)
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 609, in create_environment
site_packages=site_packages, clear=clear))
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 672, in install_python fix_lib64(lib_dir)
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 891, in fix_lib64
if [p for p in distutils.sysconfig.get_config_vars().values()
File "/usr/lib/python2.5/distutils/sysconfig.py", line 499, in get_config_vars func()
File "/usr/lib/python2.5/distutils/sysconfig.py", line 351, in _init_posix filename = get_makefile_filename()
File "/usr/lib/python2.5/distutils/sysconfig.py", line 210, in get_makefile_filename
return os.path.join(lib_dir, "config" + (sys.pydebug and "_d" or ""), "Makefile")
AttributeError: 'module' object has no attribute 'pydebug'
I get this error by doing this command:
virtualenv -p python2.5 .
Because Ubuntu10.04 doesn't come with Python2.5 I installed it from:
https://launchpad.net/~fkrull/+archive/deadsnakes
First I thought that I should installed virtualenv for Python2.5 also but that doesn't seem to work either. If I try to create a virtualenv with the following command:
sudo Python2.5 /usr/lib/python2.5/site-packages/virtualenv.py .
I end up getting the same error. I am kinda new to Ubuntu and Python and there are stil a few blank spot. Like if you have two version of Python, for Python2.6 I can just do virtualenv . But I guess to use the 2.5 one I have to call it directly like I did in the sudo command above?
Or is it completely wrong and all virtualenvs are the same and can be used with different Python versions?
Anyway my main question is how I can fix the error so I can setup a virtualenv using Python2.5. Any extra information is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
将为您提供一个特定于 python 2.5 的 virtualenv。使用 virtualenv-2.5 调用它。如果您没有 easy_install,您可能需要先 apt-get install setuptools。
will give you a python 2.5-specific virtualenv. Invoke it using virtualenv-2.5. You may need to apt-get install setuptools first if you don't have easy_install.
我能够在 Ubuntu 10.04 Lucid Lynx(默认情况下安装了 Python 2.6)中实现这一点,如下所示:
使用位于 https://launchpad.net/~fkrull/+archive/deadsnakes。
<块引用>
如果您不知道如何执行此操作:
1a。编辑 /etc/apt/sources.list,添加以下行: deb http://ppa.launchpad。 net/fkrull/deadsnakes/ubuntu 清晰的主
1b.运行“sudo apt-get update”。
1c.运行“sudo apt-get install python2.5”。
1d。通过运行“which python2.5”验证 python2.5 是否位于 PATH 中。
运行“virtualenv -p python2.5 ENV”(其中 ENV 是您想要调用的环境目录)。
然后你可以做一些平常的事情,比如'. env/bin/activate' 等等。这种方法对我来说效果很好,但如果您的设置遇到问题,请告诉我。
I was able to get this going in Ubuntu 10.04 Lucid Lynx (which comes with Python 2.6 installed by default) like so:
Install Python 2.5 using the repository at https://launchpad.net/~fkrull/+archive/deadsnakes.
Run 'virtualenv -p python2.5 ENV' (where ENV is whatever you want to call your environment directory).
You can then do the usual stuff like '. env/bin/activate' and so on. This method worked just fine for me, but let me know if run into problems with your setup.
您不需要安装两个 virtualenv。您可以使用
--python
参数告诉 virtualenv 使用哪个 python,如下所示:You don't need two virtualenvs installed. You can tell virtualenv which python to use by using the
--python
argument as follows:我安装了其他一些Python 2.5。我忘记了名字,但是类似 Python 2.5 最小版本,它给 deadsnakes 安装带来了一些问题。当我卸载它时,一切都开始正常工作。
I had some other Python 2.5 installed. I forgot the name but something like Python 2.5 minimal and it gave some problems with the deadsnakes install. When I uninstall it everything started working fine.