Python Virtual Environment: virtualenv

Source: Internet
Author: User
Tags virtual environment virtualenv

Virtualenv is a module used to create a standalone Python environment, and multiple python are independent from each other and can:
1. Install the new kit without permission
2. Different applications can use different versions of the kit
3. Package upgrade does not affect other applications

Virtualenv installation under Ubuntu:

sudo apt-get install python-virtualenv or

sudo pip install virtualenv

How to use:

1. Create a virtual environment named MySite:

Virtualenv MySite

This creates a general default Python2 environment (if direct PIP is installed) because Virtualenv chooses his hosting environment by default

If you want to create a virtual environment that specifies a Python version and does not contain any packages (installed on your own)

virtualenv–p/usr/bin/python3.5--no-site-packages MySite

Use –p to point to the Python environment by--no-site-packages to specify packages that are not dependent on the external Python environment

This makes it easy to create a virtual environment of your own.

2. Enter the virtual environment:

source./mysite/bin/activate

!! Source is a command to enter the virtual environment, and the following path points to the bin/activate in the created virtual environment

Writes based on the current path.

When you enter a virtual environment, the command line changes, with the name of the virtual environment in front of it

After entering the virtual environment, first identify the packages that are in the environment and install the required packages

PIP List # View packages and modules in the current environment

Pip Install "name" #安装所需要的模块

3. Exit the Virtual environment:

Deactivate

4. Delete the virtual environment:

RM–RF MySite #就是一个彻底删除文件夹操作, carefully confirm

Python Virtual Environment: virtualenv

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.