Installation and use of Python virtual environment virualenv _python

Source: Internet
Author: User
Tags virtual environment virtualenv

Objective

After installing tools such as Python and pip,setuptools, you can create a virualenv virtual environment, a virtual machine-like tool that lets you run multiple versions of the Python program on the same computer, without affecting each other, and then exiting or deleting it, A very good development tool.

I. Installation of VIRTUALENV

#install Pip on Mac
Brew install Python
Curl Https://bootstrap.pypa.io/ez_setup.py-o-| sudo python
sudo eas Y_install pip
#install virtualenv by pip
Pip install virtualenv

Second, the use of virtualenv

#创建一个叫做pythonEnv的新环境
virtualenv pythonenv
#激活再使用
cd pythonenv
source bin/activate
#退出环境
Deactivate

Third, using Virtualenvwrapper to manage virtual environments

Install Virtualenvwrapper

Pip Install Virtualenvwrapper

To configure environment variables:

Vim ~/.bash_profile
# virtualenv/virtualenvwrapper
source/usr/local/bin/virtualenvwrapper.sh
# exit Vim
Source ~/.bash_profile

Creating an environment

Mkvirtualenv pythonenv #在 ~/envs Create a pythonenv folder
mkvirtualenv python3env-p python3.5 #创建python3.5 environment

Switch Environment:

Workon pythonenv

Exit Environment:

Deactivate

To delete an environment:

Rmvirtualenv pythonenv

Other

1. Other Orders

Lsvirtualenv #列举所有的环境.
cdvirtualenv #导航到当前激活的虚拟环境的目录中, for example, so you can browse its site-packages.
Cdsitepackages #和上面的类似, but is directly into the Site-packages directory.
lssitepackages #显示 The contents of the Site-packages directory.

References: http://virtualenvwrapper.readthedocs.io/en/latest/command_ref.html

2. Importerror:no module named extern error occurs when the PIP is installed using the Easy_install command

Reason: Mac self-python2.7.12 extern module not installed

Solution:

#download from https://pypi.python.org/pypi/extern/0.1.0
tar zxf extern-0.1.0.tar.gz && python setup.py Install

Summarize

The above is the entire content of this article, I hope the content of this article for everyone's study or work can bring certain help, if you have questions you can message exchange.

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.