ubuntu system
first download the python environment management tool virtualenv
sudo apt-get install virtualenv
Then install virtualenvwrapper, wrapper is dependent on virtualenv
pip install virtualenvwrapper
(In windows, install virtualenvwrapper-win)
Generally speaking, workon can be executed.
If workon: command not found error occurs when using workon, it
means that virtualenvwrapper is not added to the environment variable
We need to configure ~/.bashrc and add virtualenv to it:
Two steps are required , 1
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
Note: .virtualenvs is the directory where you are going to store the virtual environment
virtualenvwrapper.sh If you can't find it, you can use
find / -name virtualenvwrapper.sh
it to find it
2. Let bashrc take effect:
Execute source ~/.bashrc
command
Other related commands:
mkvirtualenv django
If you need to specify the python environment version
mkvirtualenv django_py37 --python=xxx/python.exe (windows cmd中)
mkvirtualenv django_py37 --python=python3.7 (Linux中,前提是有python3.7)
activation
activate
Deactivation
deactivate
Enter or switch django virtual environment
workon django
Another: If some python packages cannot be downloaded, you can
download them from the python package download address here