Using virtualenv to manage the Python environment __python

Source: Internet
Author: User
Tags virtual environment virtualenv
virtualenv Introduction

A tool to create a stand-alone virtual python environment. problem solved application of the Python version inconsistency application dependent module version inconsistency application version inconsistency virtualenv installation using PIP installation (Pip 1.3+)

Pip Install Virtualenv
virtualenv Use Creating an environment
$ virtualenv ENV

Where the env is the environment directory.

Common parameter Description:

Parameters Description
–version View Program version
-H,--help Help information
-V,--verbose More information
-Q,--quiet Reduce information
-P Python_exe,--python=python_exe Set the environment Python version, such as –python=python2.5
--clear Clear the non-root user installation
--system-site-packages Using Global Packages
--no-site-packages Deprecated, default options
--extra-search-dir Search Directory for Expansion packs
Activating the Environment
$ source Bin/activate
Undo Environment
$ deactivate
Remove Environment
(ENV) $ deactivate
$ rm-r/path/to/env
configuration file

Unix/linux Directory: $HOME/.virtualenv/virtualenv.ini
Windows Catalog:%appdata%\virtualenv\virtualenv.ini

[Virtualenv]
Python =/opt/python-3.3/bin/python
extra-search-dir =
    /path/to/dists
    /path/to/other/dists
Virtualenvwrapper

For ease of use, you can also install Virtualenvwrapper with PIP, extending the virtualenv. function: consolidate all virtual environments in one directory manage (add, remove, replicate) Virtual Environment Fast switch virtual Environment installation Method

Pip Install Virtualenvwrapper
Create a directory to store a virtual environment
Mkvirtualenv-p Python3 py3env
Other common commands
Deactivate                # Exit the current virtual environment
Workon [virtual Environment name]       # Use a virtual environment
rmvirtualenv [virtual Environment name] # to delete a virtual environment
Lsvirtualenv              # List all virtual environments
Package Management Export Package List
Pip freeze-l > Packages.txt
installation Package List
Pip Install-r packages.txt
using Virtual environments in Pycharm

File-setting-project Interpreter-add Local

Reference:
Virtualenv GitHub
Virtualenv Docs
Virtualenvwrapper Docs

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.