How can [Python] use virtualenvwrapper to switch between different versions of Python? __python

Source: Internet
Author: User
Tags mkdir virtual environment virtualenv


I've long heard that virtualenv is one of the essential artifacts of Python, But always feel that the Mac python2.7 is very easy to use, as if there is no need for virtualenv, but today on the 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. Install 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 (List of notes. Localpython)

Make

Make install

3. Create an environment

Mkvirtualenv env27

Mkvirtualenv-p/users/heliclei/.localpython/bin/python3.4 env34 (notes. Localpython directory)

This creates the python2.7 and 3.4 Two versions of the virtual environment, respectively.

4. Switch

Workon env27

Look at the Python version.

Python--version

>>python 2.7.6

and cut to 3.4 of the environment.

Workon env34

Check the version.

Python--version

>>python 3.4.0

It appears that two versions of Python are working correctly:

5.

Exit Environment: Deactivate

Delete environment: Rmvirtualenv env_name

Reprinted from: http://www.2cto.com/os/201412/365570.html (verified available.) )

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.