我正在运行 macOS Sierra 版本 10.12.2,尝试安装一个与系统预装的 Python 2.7.10 版本不同的 Python 版本。我被建议安装一个新版本的 Python,否则可能会破坏系统 Python 的安装。
我已经使用 brew 安装了 Python 2.7.13:
然而,我的终端仍然默认为系统安装。
我已经使用 brew 安装了 Python 2.7.13:
brew install python
然而,我的终端仍然默认为系统安装。
$ python
Python 2.7.10 (default, Jul 30 2016, 19:40:32)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
如何安装更新的(非系统)Python 2.7版本,并让操作系统识别并默认使用新版本(2.7.13)?
编辑:
当我在.bash_profile
文件中更新以下内容后,启动bash终端时会出现错误。
PATH="/usr/local/Cellar/python/2.7.13/bin:${PATH}"
export "$PATH"
我收到的错误是:
-bash: export: `/usr/local/Cellar/python/2.7.13/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin': not a valid identifier
brew
会将 Python 安装在/usr/local/Cellar/python/2.7.13/bin/python2.7
。 - Borealis