欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

ubuntu18+virtualenv配置

程序员文章站 2022-04-29 19:05:48
思路: 1、两条命令安装,加sudo是安装在/usr/local/bin/virtualenv路径下,不加就安装在home/.local下。注意,后面bashrc里,要设置的路径和这个有关系,所以要区分清楚 pip3 install virtualenv pip3 install virtualen ......

思路:

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:~$

执行结果如上。大功告成!