0

I've got a py2.7 project which I want to test under py3.2. For this purpose, I want to use virtualenv. I wanted to create an environment that would run 3.2 version internally:

virtualenv 3.2 -p /usr/bin/python3.2

but it failed. My default python version is 2.7 (ubuntu default settings). Here is virtualenv --version 1.10. The error output is:

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

I don't know what the hell is this syntax error - where does it come from... I know there was a change in try...catch statement syntax between 2.x and 3.x, but should virtualenv throw syntax errors?

I'd be grateful if someone pointed me out if there's something I'm doing wrong or if there is an installation problem on my machine.

1

3 Answers 3

2

To create a Python 3.2 virtual environment you should use the virtualenv you installed for Python 3.2. In your case that would be:

/usr/bin/virtualenv-3.2
Sign up to request clarification or add additional context in comments.

Comments

1

You'll have to use a Python 3 version of virtualenv; the version you are using is installing Python 2 tools into a Python 3 virtual environment and these are not compatible.

2 Comments

I installed my current virtualenv within this: sudo pip install virtualenv. I guess it used the default py version which is 2.7. How can I install a different virtualenv version? I couldn't find it in install/docs
Use the python3-pip package; it has a pip-3.2 command. sudo pip-3.2 install virtualenv should do it.
0
virtualenv --python=/usr/bin/python3.2 --no-site-packages ENV

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.