设置virtualenvwrapper以使用Python 2.7.9

时间:2016-04-16 09:06:18

标签: python python-2.7 virtualenv

出于工作原因,我必须使用Python 2.7.9。在我的系统OS X Yosemite上,我有版本2.7.11。有一种方法可以通过virtualenvwrapper设置环境以使用特定版本的Python吗?

2 个答案:

答案 0 :(得分:1)

查看-p选项:

$ virtualenv --help
Usage: virtualenv [OPTIONS] DEST_DIR

Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -v, --verbose         Increase verbosity.
  -q, --quiet           Decrease verbosity.
  -p PYTHON_EXE, --python=PYTHON_EXE
                        The Python interpreter to use, e.g.,
                        --python=python2.5 will use the python2.5 interpreter
                        to create the new environment.  The default is the
                        interpreter that virtualenv was installed with
                        (/usr/bin/python3.5)

您需要先在系统上安装Python 2.7.9。正如另一个答案中所说,您可以在系统上并排安装多个Python版本。

答案 1 :(得分:0)

您可以在同一系统上拥有多个python二进制文件。安装所需的版本并使用此命令。

@Subscribe
public void onEvent(List<okHTTP_dataProvider> infoModels) {

};

virtualenv -p {python binary location} {name of virtualenv} 命令virtualenvwrappermkvirtualenv都会接受mkproject参数,并在创建虚拟环境时将其传递给-p