【发布时间】:2018-01-19 05:48:02
【问题描述】:
这是我第一次在这里提问,如果我做错了什么,请提前道歉。问题是我使用 Homebrew 安装了 python 2 以避免使用 OS X 系统 python(因为建议这样做),但是当我输入终端 - python 时,它仍然使用系统 python。
which -a python 给出: /usr/bin/python
写python给出:
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
并且做 python2 给出:
Python 2.7.13 (default, Jul 18 2017, 09:16:53)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
我只想写 python 而不是 python2 来使用 Homebrew 版本。
另外,回显 $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin
和 /etc/paths
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/etc/paths (END)
我应该怎么做才能使用 Homebrew python 而不是默认的系统 python。 PD我也用 Hombrew 安装了 python 3。
【问题讨论】:
-
您可以在您的
.bash_profile中设置一个别名,以便命令python执行安装的Homebrew,但我建议使用pyenv来更好地组织您所有的python 版本。 -
您是否打开了一个新的终端会话?除非您开始新会话或
source您的个人资料,否则您现有的会话将不会有新的 PATH。
标签: macos python-2.7 homebrew