我有一个py2.7项目,我想在py3.2下测试。为此,我想使用virtualenv。我想创建一个内部运行3.2版本的环境:
virtualenv 3.2 -p /usr/bin/python3.2
但失败了。我的默认python版本是2.7
(ubuntu默认设置)。这是virtualenv --version 1.10
。错误输出是:
Running virtualenv with interpreter /usr/bin/python3.2
New python executable in 3.2/bin/python3.2
Also creating executable in 3.2/bin/python
Installing Setuptools...................................................................................................................................................................................................................................done.
Installing Pip..............
Complete output from command /home/tomasz/Develop...on/3.2/bin/python3.2 setup.py install --single-version-externally-managed --record record:
Traceback (most recent call last):
File "setup.py", line 5, in <module>
from setuptools import setup, find_packages
File "/usr/lib/python2.7/dist-packages/setuptools/__init__.py", line 2, in <module>
from setuptools.extension import Extension, Library
File "/usr/lib/python2.7/dist-packages/setuptools/extension.py", line 2, in <module>
from setuptools.dist import _get_unpatched
File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 103
except ValueError, e:
^
SyntaxError: invalid syntax
----------------------------------------
...Installing Pip...done.
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 2308, in <module>
main()
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 821, in main
symlink=options.symlink)
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 963, in create_environment
install_sdist('Pip', 'pip-*.tar.gz', py_executable, search_dirs)
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 932, in install_sdist
filter_stdout=filter_install_output)
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 899, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /home/tomasz/Develop...on/3.2/bin/python3.2 setup.py install --single-version-externally-managed --record record failed with error code 1
我不知道这个语法错误到底是什么 - 它来自哪里......我知道2.x和3.x之间的try ... catch语句有一个变化,但应该是virtualenv抛出语法错误?
如果有人指出我是否有错误,或者我的机器上出现安装问题,我将不胜感激。
答案 0 :(得分:2)
要创建Python 3.2虚拟环境,您应该使用为Python 3.2安装的virtualenv。在你的情况下:
/usr/bin/virtualenv-3.2
答案 1 :(得分:1)
您必须使用{3}的Python 3版本;您正在使用的版本是将Python 2工具安装到Python 3虚拟环境中,这些工具不兼容。
答案 2 :(得分:0)
virtualenv --python=/usr/bin/python3.2 --no-site-packages ENV