“python” 指向 macOS Homebrew 下的 Python 2.7

“python” 指向 macOS Homebrew 下的 Python 2.7

无法运行 python 3.7.2

我正在尝试通过 Django 设置和运行服务器,但似乎无法让 Python 3.7.2 取代 Python 2.7.14。

答案1

请阅读印刷的信息brew info python。它还链接到Python 上的 Homebrew 网站,其中写道:

可执行文件的组织方式如下,以便 Python 2 和 Python 3 都可以无冲突地安装:

  • python3指向 Homebrew 的 Python 3.x(如果已安装)
  • python2指向 Homebrew 的 Python 2.7.x (如果已安装)
  • python指向 Homebrew 的 Python 2.7.x(如果已安装)否则指向 macOS 系统 Python。检查brew info python是否要将 Homebrew 的 3.x python 添加到您的 PATH。
  • pip3指向 Homebrew 的 Python 3.x 的 pip(如果已安装)
  • pip并且 pip2 指向 Homebrew 的 Python 2.7.x 的 pip (如果已安装)

显然,您已通过 Hombrew 安装了 Python 2 和 3。如果您希望python指向 Python 3(而不是 2.7),则必须/usr/local/opt/python/libexec/bin输入PATH 其他条目。

相关内容