[Python] How do I switch between different versions of Python using Virtualenvwrapper?

Source: Internet
Author: User
Tags virtualenv

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?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.