安装virtualenv及autoenv
# 安装virtualenv
# sudo apt install -y virtualenv
$ pip3 install virtualenv
$ mkdir python-project-name
$ cd python-project-name
$ virtualenv -p python3 venv
$ source venv/bin/activate
$ git clone git://github.com/kennethreitz/autoenv.git ~/.autoenv
$ vim ~/.zshrc
AUTOENV_ENABLE_LEAVE='yes'
source ~/.autoenv/activate.sh
# 在python项目目录下新建.env和.env.leave文件,并在文件里写入shell命令
$ cd python-project-name
$ cat .env
source `dirname $0`/env/bin/activate
$ cat .env.leave
deactivate