I've heard that Virtualenv is one of the essential Python artifacts, But always feel that Mac comes with python2.7 is very useful, as if there is no need to use virtualenv, but today on GitHub to see a new Python open source project, need to use Python3, so must virtualenv.
1. Install virtualenv, Virtualenvwrapper
sudo pip install virtualenv
sudo pip install Virtualenvwrapper
2. Installing python3.4
mkdir ~/SRC
CD ~/src/
wget http://www.python.org/ftp/python/3.4.0/Python-3.4.0.tgz
TAR-ZXVF python-3.4.0.tgz
CD Python-3.4.0
mkdir ~/.localpython
./configure--prefix=/users/heliclei/.localpython
Make
Make install
3. Create an environment
Mkvirtualenv env27
Mkvirtualenv-p/users/heliclei/.localpython/bin/python3.4 env34
This establishes the python2.7 and 3.4 Two versions of the virtual environment, respectively.
4. Toggle
Workon env27
Take a look at the Python version
Python--version
>>python 2.7.6
And then cut to 3.4 of the environment.
Workon env34
Check the version.
Python--version
>>python 3.4.0
It looks like two versions of Python are working correctly:)
5.
Exit Environment: Deactivate
Delete environment: rmvirtualenv env_name
[Python] How do I switch between different versions of Python using Virtualenvwrapper?