如果存在几个,如何选择python可执行文件



我想使用 Python/C API 执行 Python 脚本(我使用的是 Mac OS X Mavericks、Xcode)。由于我的机器上安装了多个 Python 发行版(System、Homebrew、多个 virtualenvs),我该如何定义使用哪个发行版?

您可以定义使用哪一个:

  • 通过指定可执行文件的完整路径;
  • 或具有不同的别名。

例如,我在这台机器上同时拥有Python 2.7和Python 3.2:

$ python
Python 2.7.3 (default, Dec 18 2012, 13:50:09)
[GCC 4.5.3] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
$ python3
Python 3.2.3 (default, Jul 23 2012, 16:48:24)
[...]
$ /usr/bin/python2.7
Python 2.7.3 (default, Dec 18 2012, 13:50:09)
[...]
$ /usr/bin/python3.2
Python 3.2.3 (default, Jul 23 2012, 16:48:24)
[...]

最新更新