when you have installed python3.5 or python2.7, then copy codes following to use python3.5 or python2.7 in virtualenv.
- install pip
$ sudo apt-get install python-pip
- use pip to install virtualenv
$ pip install virtualenv
- make a directory noly for virtualenv environment
$ mkdir virtualenvs
- Install python3.5 virtualenv, "--no-site-packages" means to make site-packages for python3.5 in virtualenv are separated from site-packages out of the virtualenv.
$ cd virtualenvs/
$ virtualenv --no-site-packages --distribute -p /usr/bin/python3.5 py3.5
- activate py3.5
$ source py3.5/bin/activate
- check the python version at present.
$ which python
- you can also deactivate py3.5
$ deactivate
- you may have python2.7 virtualenv as well. Use code like py3.5.
$ virtualenv --no-site-packages --distribute -p /usr/bin/python2.7 py2.7
If you have two python version (python2 and python3),you can use sudo apt install virtualenv
Also, you can use source py3.5/bin/activate
and deactivate
to change python versions.