Ubuntu16.04
Upgrade pip
sudo pip install --upgrade pip
Install virtual environment
sudo pip install virtualenv
sudo pip install virtualenvwrapper
virtualenvwrapper is an extended management package of virtualenv, which can integrate all virtual environments in one directory.
Configure virtual environment
sudo mkdir ~/.envs
sudo gedit ~/.bashrc
export WORKON_HOME=$HOME/.envs #All virtual environment storage directories
source /usr/local/bin/virtualenvwrapper.sh
source ~/.bashrc
Solution, re-add python-related environment variables:
(Be sure to confirm the Python version that virtualenvwrapper depends on first)
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
Virtual environment operation
Create a virtual environment
env_name is the name of the virtual environment you want to create, which needs to be connected to the Internet
mkvirtualenv env_name
mkvirtualenv -p /usr/bin/python3.6 python36_
mkvirtualenv -p /usr/bin/python2.7 python27_
workon
workon env_nam
deactivate
rmvirtualenv env_nam
Export the installed library to list.txt
pip freeze > list.txt
Import the libraries listed in list.txt to the system
pip install -r list.txt
Recommended Posts