Python 虚拟环境 virtualenvwrapper

安装

1
2
pip3 install virtualenvwrapper
mkdir ~/.virtualenvs

查找virtualenvwrapper.sh

1
which virtualenvwrapper.sh

配置文件

~/.bash_profile :

1
2
3
4
5
6
7
8
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$DEV_PATH/workspace
export VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'

source /usr/local/bin/virtualenvwrapper.sh

请对应真实路径

使用

1
2
3
4
5
6
7
8
9
10
11
12
$ mkvirtualenv test --python=python3

$ lsvirtualenv
test
====

workon test

## 退出环境test
deactivate
## 删除环境test
rmvirtualenv test

其它

1
2
3
pip freeze > requirements.txt

pip install -r requirements.txt

Powered by Hexo and Hexo-theme-hiker

Copyright © 2013 - 2021 朝着牛逼的道路一路狂奔 All Rights Reserved.

访客数 : | 访问量 :