思路:
1、两条命令安装,加sudo是安装在/usr/local/bin/virtualenv路径下,不加就安装在home/.local下。注意,后面bashrc里,要设置的路径和这个有关系,所以要区分清楚
pip3 install virtualenv
pip3 install virtualenvwrapper
2、安装完,在bashrc里添加三条命令,第一条指定python版本,第二条指定虚拟环境工作目录,第三条是激活shell下面的快捷命令比如workon等
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
@ubuntu:~$ source .bashrc
virtualenvwrapper.user_scripts creating /home/leiting/.virtualenvs/premkproject
virtualenvwrapper.user_scripts creating /home/leiting/.virtualenvs/postmkproject
virtualenvwrapper.user_scripts creating /home/leiting/.virtualenvs/initialize
virtualenvwrapper.user_scripts creating /home/leiting/.virtualenvs/premkvirtualenv
virtualenvwrapper.user_scripts creating /home/leiting/.virtualenvs/postmkvirtualenv
virtualenvwrapper.user_scripts creating /home/leiting/.virtualenvs/prermvirtualenv
virtualenvwrapper.user_scripts creating /home/leiting/.virtualenvs/postrmvirtualenv
virtualenvwrapper.user_scripts creating /home/leiting/.virtualenvs/predeactivate
virtualenvwrapper.user_scripts creating /home/leiting/.virtualenvs/postdeactivate
virtualenvwrapper.user_scripts creating /home/leiting/.virtualenvs/preactivate
virtualenvwrapper.user_scripts creating /home/leiting/.virtualenvs/postactivate
virtualenvwrapper.user_scripts creating /home/leiting/.virtualenvs/get_env_details
@ubuntu:~$
执行结果如上。大功告成!
原文地址:https://www.cnblogs.com/noobcoder17/p/11378049.html