苹果(MAC)操作系统(OSX)上设置Python3为Python命令启动的方式

通过HomeBrew安装的Python启动命令为Python3,pip3

HomeBrew安装Python的命令为:

brew install python

然而,很多脚本里Python的启动命令为Python

如何使OSX上的Python3命令通过Python启动呢?

1.执行下列命令

brew info python

  会得到如下输出信息:

==> python@3.12: stable 3.12.3 (bottled)
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/usr/local/Cellar/python@3.12/3.12.2_1 (3,238 files, 63.6MB)
  Poured from bottle using the formulae.brew.sh API on 2024-03-27 at 19:51:29
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/p/python@3.12.rb
License: Python-2.0
==> Dependencies
Build: pkg-config ✔
Required: mpdecimal ✔, openssl@3 ✔, sqlite ✔, xz ✘
==> Caveats
Python has been installed as
  /usr/local/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /usr/local/opt/python@3.12/libexec/bin

See: https://docs.brew.sh/Homebrew-and-Pythonz 

注意这部分:

==> Caveats
Python has been installed as
  /usr/local/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /usr/local/opt/python@3.12/libexec/bin

  告诉你如何设置链接到Python命令的方法。

2.执行下列语句设置链接

export PATH=/usr/local/opt/python@3.12/libexec/bin:$PATH

  这里要注意你自己操作系统安装的Python的版本可能和我不同。

posted @ 2024-04-14 21:43  West Continent  阅读(81)  评论(0编辑  收藏  举报