The Installation Process of the python virtual environment in ubuntu environment, ubuntupython
1. Virtual Environment Construction
How to install a module in development:
Pip install Module name
Previously, our installation modules were directly installed in the physical environment. This installation method overwrites the previous one. What if multiple projects developed on one machine use modules of different versions? How can we do this without affecting the version! You need to use a virtual environment. Each virtual environment is isolated from each other. Installing and uninstalling modules in a virtual environment is not affected!
1. python Virtual Environment Installation
sudo apt-get install python-virtualenvsudo easy_install virtualenvwrapper
After the tool is installed, the mkvirtualenv command cannot be found. You need to execute the following environment variable settings.
1. Create a directory to store the Virtual Environment
mkdir $HOME/.virtualenvs
2. In ~ /. Add rows to bashrc:
export WORKON_HOME=$HOME/.virtualenvssource /usr/local/bin/virtualenvwrapper.sh
3. Run:
source ~/.bashrc
3. Create a python Virtual Environment
Mkvirtualenv [Virtual Environment name] workon [Virtual Environment name]
4. Exit the Virtual Environment
Deactivate [Virtual Environment name]
5. Delete (use with caution) and return to the virtual environment first
Rmvirtualenv [Virtual Environment name]
6. Create python 2 for development
mkvirtualenv -p /usr/bin/python2.7 py2
7. Create python 3 for development
mkvirtualenv -p /usr/bin/python3 py3
2. Install the specified version number of the module in the virtual environment
1. You do not need to add sudo to the installation module in the virtual environment. If you add sudo, it will be installed in the real environment, and you do not need to specify the pip version. You can directly use pip for installation.
workon py3 pip install django==1.8.2
2. Check the packages installed in the virtual environment.
pip freeze list
3. After the project is developed, you need to export and install the packages used in the development environment to the production environment.
pip freeze list > package.txt
4.install the package.txt file of the development environment to the production environment
Summary
The above is the installation process of the python Virtual Environment In ubuntu. I hope it will be helpful to you. If you have any questions, please leave a message, the editor will reply to you in time!