virtualenv enables multiple python to be independent from each other, and it can:
1. Install the new kit without permission
2. Different applications can use different versions of the kit
3. Package upgrade does not affect other applications
Installation
sudo apt-get install python-virtualenv
Then set up a test directory
mkdir py/django_pro-pcd py/django_pro/virtualenv web01cd web01source bin/activate exiting the virtual environment: deactivate
At this point we'll find one more in front of the shell prompt (WEB01), which means we're already in the Python virtual environment, where we can install any Python library without worrying about messing up the system's Python library.
Note: By default, the virtual environment relies on site packages in the system environment, which means that the installed third-party package in the system will also be installed in the virtual environment, if you do not want to rely on the package, Then you can add the--no-site-packeages parameter. That is virtualenv--no-site-packages web02, you can also create an alias for Virtualenv, which is vim ~/.BASHRC then add virtualenv= ' virtualenv-- No-site-packages ' "
virtauleNvwrapper is a virtualenv expansion pack for easier management of virtual environments that can do:
"You do not need to use source [path] to create"
1. Integrate all virtual environments into a single directory
2. Manage (add, delete, copy) virtual environment
3. Switch Virtual Environment
sudo pip install Virtualenvwrapper
Installation is complete, but at this time can not use Virutalenvwrapper, the default virutalenvwrapper is installed under/usr/local/bin, we need to run the virtualenvwrapper.sh file. We can view the file first, there are configuration steps.
1. Create a directory to hold the virtual environment mkdir ~/.virtualenvs # I have finished installing Virtualenvwrapper, the directory has been created by default 2. Added in the ~/.BASHRC file: Export WORKON_HOME=/HOME/MILO/.VIRTUALENVS3. Added in ~/.BASHRC: Source/usr/local/bin/virtualenvwrapper.sh4. Run Source ~/.BASHRC
At this point the Virtualenvwrapper is ready to use.
List Virtual environments: Workon, lsvirtualenv
New virtual Environment: Mkvirtualenv WEB03
Start/Switch Virtual environment: Workon WEB02
Delete Virtual environment: Rmvirtualenv WEB01
Leaving the virtual environment: deactivate
This article is from "Hello Tech" blog, please make sure to keep this source http://ninefive.blog.51cto.com/9469723/1566878
ubuntu10.0.4 virtualenv Creating a virtual Python environment