|
virtualenv
virtualenv environment for creating standalone Python, Python plurality of mutually independent of each other, it can:
1. Install the new kit in the case without permission
2. The different applications can use different versions of packages
3. Upgrade kit does not affect other applications
installation
sudo apt-get install python-virtualenv
Instructions
virtualenv [virtual environment name]
For example, to create a virtual environment ** ENV **
virtualenv ENV
By default, the virtual environment will depend on the system environment site packages, that is to say the system has been installed third-party package will be installed in the virtual environment, if you do not want to rely on these package, you can add parameters --no-site -packages create a virtual environment
virtualenv --no-site-packages [name of the virtual environment]
Start Virtual Environment
cd ENV
source ./bin/activate
Note that this time will be more than a command line (ENV), ENV virtual environment name, then all modules will only be installed into that directory.
Exit Virtual Environment
deactivate
Python installation kit in a virtual environment
Virtualenv pip comes with installation tools, so you need to install the kit can be run directly:
pip install [package name]
If you do not start the virtual environment, the system also installed pip tool, the kit will be installed in the system environment, in order to avoid this, you can add in ~ / .bashrc file:
export PIP_REQUIRE_VIRTUALENV = true
Pip or let in the implementation of the system automatically turn on the virtual environment:
export PIP_RESPECT_VIRTUALENV = true
Virtualenvwrapper
Virtaulenvwrapper virtualenv is an expansion pack for easier management of the virtual environment, it can be done:
1. Place all in a virtual environment integration directory
2. management (add, delete, copy) Virtual Environment
3. Switch Virtual Environment
4. ...
installation
sudo easy_install virtualenvwrapper
In this case you can not use virtualenvwrapper, virtualenvwrapper default installed in / usr / local / bin Now, you actually need to run the file virtualenvwrapper.sh job, do not worry, open the file and see, there are installation procedures, we operate according to the environment is set up.
1. Create a directory to store the virtual environment
mkdir $ HOME / .virtualenvs
2. ~ / .bashrc add line: export WORKON_HOME = $ HOME / .virtualenvs
3. ~ / .bashrc to add a row: source /usr/local/bin/virtualenvwrapper.sh
4. Run: source ~ / .bashrc
At this point you can use virtualenvwrapper.
Lists the virtual environment list
workon
You can also use
lsvirtualenv
New Virtual Environment
mkvirtualenv [virtual environment name]
Start / switch the virtual environment
workon [virtual environment name]
Delete Virtual Environment
rmvirtualenv [virtual environment name]
Leave the virtual environment
deactivate |
|
|
|