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:
Exit Environment:
To delete an environment:
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.