Python Third Party Library series 26--virtualenv Library

Source: Internet
Author: User
Tags virtualenv

What Virtualenv is. Virtualenv is a tool to create isolated Python environments. In order to isolate different versions of the development environment (if the project is collaborative development, the version of the library problem is a headache, with this can be in their own environment to run).

Step one, install Virtualenv: (PIP installation refer to Python third Party Library series 25--pip Library)

$ pip Install virtualenv
//or by using sudo temporary elevation privileges for permissions issues
$ sudo pip install virtualenv

Step two, and then run the command virtualenv

$ virtualenv ENV        //env is the name of this isolated environment
installing Setuptools......done
installing Pip...................done 
$cd env
$ls
bin  include  Lib  local          //You can see that these four directories are created in the Env isolation environment.

Here are the next few important subdirectories:

Env/lib/pythonx.x/site-packages: All libraries installed in an isolated environment are installed in this directory

The operating environment of the Env/bin/python:python parser

Step three, enter the isolated environment

into the environment in other words is said: Change the shell environment variable $path

Xxx@xxx:~/env$source/bin/activate
(ENV) xxx@xxx:~/env$

You'll find out more here (ENV), which means you're already in an isolated environment, and you want to exit the environment with the Deactivate command.

The environment between activate and deactivate is to isolate the environment, and all of the operations you want to isolate are between these two commands.

Step four, use the PIP command

$pip Freeze > Requirements.txt//Save package dependency information in Requirements.txt file
$pip install-r requirements.txt// The PIP automatically downloads and installs all the packages in the file from the Web.
$pip Install somepackage==1.0//install a software called Somepackage, version 1.0
$pip Uninstall somepackage/Uninstall Somepackage

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.