使用virtualenvwrapper(&virtualenv)更改默认python版本

Yun*_*nti 16 python virtualenv virtualenvwrapper

我最近改变了我的python设置,现在它已经安装了brew.以前使用virtualenv和virtualenvwrapper时,它默认使用python3设置一个新的virtualenv(用于我的大多数项目).现在不幸的是默认是python2.我可以使用以下命令安装python3:

mkproject -p python3 projectname
Run Code Online (Sandbox Code Playgroud)

但是我怎样才能使python3成为默认值?

Joe*_*ung 26

要自动使用自定义Python二进制文件而不是运行一个virtualenv,您还可以设置一个环境变量:

$ export VIRTUALENV_PYTHON=/opt/python-3.3/bin/python
$ virtualenv ENV
Run Code Online (Sandbox Code Playgroud)

这与直接将选项传递给virtualenv相同:

$ virtualenv --python=/opt/python-3.3/bin/python ENV
Run Code Online (Sandbox Code Playgroud)

来源:https://virtualenv.pypa.io/en/latest/reference.html#configuration