Methods for installing modules in development:
Pip Install module name
Before we installed the modules are directly in the physical environment installation, this installation method, the subsequent installation will overwrite the previous installation. What if a single machine developed multiple projects using different versions of the module? What to do to not be affected by the version! Then need to use the virtual environment, each virtual environment isolated from each other, in a virtual environment loading module other not affected!
1. Python Virtual Environment installation
sudo apt-get install python-virtualenvsudo easy_install virtualenvwrapper
The mkvirtualenv command is not found when the above tool is installed, and the following environment variable settings are required.
1. Create a directory to store the virtual environment
$HOME/.virtualenvs
2. Add lines in ~/.BASHRC:
Export workon_home=$HOME/.virtualenvssource/usr/local/bin/virtualenvwrapper.sh
3. Run:
~/.bashrc
3. Create a Python virtual environment
mkvirtualenv [Virtual Environment name]workon [virtual environment name]
4. Exiting the virtual environment
Deactivate [virtual Environment name]
5. Delete (use caution) first return to the virtual environment
rmvirtualenv [Virtual Environment name]
6. Create Python 2 version development
Mkvirtualenv-p/usr/bin/python2.7 Py2
7. Create Python 3 version development
Mkvirtualenv-p/usr/bin/python3 Py3
2. Install the module with the specified version number in the virtual environment
1. Installing the module in a virtual environment does not require sudo, if add sudo will be installed in the real environment, do not need to specify the version of PIP, directly using PIP installation can.
Workon py3 pip Install django= =1.8.2
2. See which packages are installed in the virtual environment
PIP Freeze List
3. Project development completed, need to be on-line, the development environment to use the package, export installation into the production environment.
> Package.txt
4. Install the file Package.txt of the package exported by the development environment into the production environment
Pip Install-r package.txt
Installation of Python virtual environment in Ubuntu environment