Creating and Using MAC python virtual environment

Installation command virtual environment:

Installation virtualenv and virtualenvwrapper

sudo pip install virtualenv install virtual environment

sudo pip install virtualenvwrapper install virtual environment

 

 

 

 Edit vim ~ / .bash_profile file modify environment variables (add lines below 6)

Add the first and last rows can also, if there is one, we'll add all.

 

 

 

export WORKON_HOME=$HOME/.virtualenvs

export VIRTUALENVWRAPPER_SCRIPT=/Library/Frameworks/Python.framework/Versions/3.7/bin/virtualenvwrapper.sh

export VIRTUALENVWRAPPER_PYTHON=/Library/Frameworks/Python.framework/Versions/3.7/bin/python3

export VIRTUALENVWRAPPER_VIRTUALENV=/Library/Frameworks/Python.framework/Versions/3.7/bin/virtualenv

export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'

source /Library/Frameworks/Python.framework/Versions/3.7/bin/virtualenvwrapper.sh

 

 

Then source ~ / .bash_profile take effect.

 

 

 

Next, create a virtual environment command

mkvirtualenv virtual environment name  

mkvirtualenv -p python3 virtual environment name (in the case of using python3)

 

Enter the virtual work environment: workon virtual environment name

Exit virtual machine environment deactivate 

 

 

Guess you like

Origin www.cnblogs.com/fanhh/p/12607501.html