Install virtualenvWrapper using PIp3

pip3 install virtualenvwrapper
Copy the code
  • Configure virtualenvWrapper to create the directory for the virtual environment and specify python3
  1. Environment edits the current user configuration variable
Mkdir ~/.virtualenvs # create a directory to store the virtual environment vim ~/.bashrcCopy the code

Add the following at the bottom of the file

Export WORKON_HOME=~/. Virtualenvs # Specify the directory for the Virtualenvwrapper environment export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3.6 The path to virtualenvwrapper can be found by using find / -name virtualenvwrapper.sh ~/.local/bin/virtualenvwrapper.sh source /usr/local/bin/virtualenvwrapper.shCopy the code
  1. Make changes to environment variables take effect
source ~/.bashrc
Copy the code
  1. The virtualenvwrapper command is too long. Make it shorter
MKV myenvs alias RMV ='rmvirtualenv' # virtualenvwrapper CMD alias MKV ='mkvirtualenv Alias LSV =' lsVirtualenv '# View all virtual environmentsCopy the code

4. Create a virtual environment

 mkv myenvs
Copy the code

Virtual environment Myenvs

5. Exit and enter the virtual environment

  • Exiting a Virtual Environment

deactivate  
Copy the code

image.png

  • Enter the Virtual Environment
Workon Myenvs # After successful entry, the name of the virtual environment will be displayed in front of itCopy the code

image.png