Creating a Python virtual environment in UBUNTU14

Source: Internet
Author: User

First, install the PYTHON-VIRTUALENV package

sudo apt-get Install virtualenv

After the installation is complete, create a Virtual Environment folder.

mkdir venv
CD venv

Create a virtual environment, pure virtual environment, and the system inside the package without a little contact. Forvirtualenv1.7或者更新版本,这是默认行为。他会在当前目录中创建文件夹env

virtualenv--no-site-packages [Virtual environment name]
#例如env
Virtualenv--no-site-packages Env

To start the virtual environment, you need to activate

SOURCE Env/bin/activate

Notice that the command prompt is changed and has a (venv) prefix that indicates that the current environment is a venv python environment named.

You can install any package via PIP or sudo apt-get install, which is installed in the virtual environment and is not associated with the package in the System file library.

Launch a virtual environment

Deactivate

If you want to delete a virtual environment, simply delete the directory.

RM-RF env

Second, back up the current virtual environment, and store the list of packages needed for the current environment for the next construction of the same environment.

Pip Freeze > Requirements.txt

will produce a file Requirements.txt file.

If you want to build the same environment, just perform

Pip Install-r requirements.txt

Creating a Python virtual environment in UBUNTU14

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.