在Ubuntu中安装Python虚拟环及virtualenvwrapper
作者:互联网
一、安装pip包管理器
- Ps:我这里使用的是deepin的15.9版本,非原生ubuntu
- 在这里默认是没有安装pip包管理器的需要手动安装
python@python:~$ sudo apt install python3-pip
二、安装virtualenv及virtualenvwrapper
sudo pip3 install virtualenv
sudo pip3 install virtualenvwrapper
sudo apt install virtualenv
三、配置~/.bashrc
source ~/.bashrc
在最后添加如下内容:
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/bin/virtualenv
source /usr/local/bin/virtualenvwrapper.sh
使配置生效
python@python:~$ source ~/.bashrc
virtualenvwrapper.user_scripts creating /home/python/HOME/.virtualenvs/premkproject
virtualenvwrapper.user_scripts creating /home/python/HOME/.virtualenvs/postmkproject
virtualenvwrapper.user_scripts creating /home/python/HOME/.virtualenvs/initialize
virtualenvwrapper.user_scripts creating /home/python/HOME/.virtualenvs/premkvirtualenv
virtualenvwrapper.user_scripts creating /home/python/HOME/.virtualenvs/postmkvirtualenv
virtualenvwrapper.user_scripts creating /home/python/HOME/.virtualenvs/prermvirtualenv
virtualenvwrapper.user_scripts creating /home/python/HOME/.virtualenvs/postrmvirtualenv
virtualenvwrapper.user_scripts creating /home/python/HOME/.virtualenvs/predeactivate
virtualenvwrapper.user_scripts creating /home/python/HOME/.virtualenvs/postdeactivate
virtualenvwrapper.user_scripts creating /home/python/HOME/.virtualenvs/preactivate
virtualenvwrapper.user_scripts creating /home/python/HOME/.virtualenvs/postactivate
virtualenvwrapper.user_scripts creating /home/python/HOME/.virtualenvs/get_env_details
四、创建虚拟环境
mkvirtualenv py_django --python=/usr/bin/python3
#指定Python版本为python3虚拟环境名为:py_django
五、激活虚拟环境
workon py_django
六、退出及删除虚拟环境
#退出
deactivate
#删除
rmvirtualenv
标签:环及,virtualenvs,Python,python,virtualenvwrapper,user,HOME,creating 来源: https://blog.csdn.net/lb0737/article/details/89041453