My default python version on my Debian 8.5 machine is 3.4.2. I want to use python 2.7 for only one project. I have tried running all of the following commands in the terminal one by one, :
virtualenv -p python2.7 env_dir
virtualenv -p python2 env_dir
virtualenv --python=python2.7 env_dir
And this is the file.py inside the env_dir:
print "Hello world from inside env_dir"
Obviously however the file.py still gets executed with python3.4.2, because i run:
python file.py
and i get:
File "file.py", line 1
print "Hello world from inside env_dir"
^
SyntaxError: Missing parentheses in call to 'print'
What is the problem, why it fails to run the code in python2.7?
Update
I have also tried:
virtualenv -p /usr/bin/python2.7 env_dir
source env_dir/bin/activate
(env_dir) amir@amir-debian:~/env_dir$ python file.py
File "file.py", line 1
print "Insid virtual env"
^
SyntaxError: Missing parentheses in call to 'print'
Running python -V
after activating returns: Python 3.4.2
Update-2 Here is the process how i try to create my virtualenv and the outputs from terminal:
$ virtualenv --python=/usr/bin/python2.7 venv3
Running virtualenv with interpreter /usr/bin/python2.7
New python executable in /home/amir/Desktop/venv3/bin/python2.7
Also creating executable in /home/amir/Desktop/venv3/bin/python
Installing setuptools, pip, wheel...done.
$ source venv3/bin/activate
(venv3) amir@amir-debian:~/Desktop$ python -V
Python 3.4.2
(venv3) amir@amir-debian:~/Desktop$ python
Python 3.4.2 (default, Oct 8 2014, 10:45:20)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
Why is the working version still 3.4.2 and not 2.7 as i gave as OPTION to vertualenv
when creating venv3?