MacBookPro 安装Python

Homebrew

假设你没有安装Homebrew,那么就执行:

/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)

安装Python

执行命令:

yutao@MacBook-Pro Homebrew % brew install Python

在这里插入图片描述
可以看到,最后报错了,原因就是我的Homnebrew,需要更新下:

执行命令:

cd "$(brew --repo)" && git fetch && git reset --hard origin/master && brew update

需要等待挺长时间,等它更新完。

然后再次执行brew install Python
然后我们会看到如下日志,日志省略了~

... ...
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.11/libexec/bin

You can install Python packages with
  pip3 install <package>
They will install into the site-package directory
  /usr/local/lib/python3.11/site-packages

tkinter is no longer included with this formula, but it is available separately:
  brew install python-tk@3.11

gdbm (`dbm.gnu`) is no longer included in this formula, but it is available separately:
  brew install python-gdbm@3.11
`dbm.ndbm` changed database backends in Homebrew Python 3.11.
If you need to read a database from a previous Homebrew Python created via `dbm.ndbm`,
you'll need to read your database using the older version of Homebrew Python and convert to another format.
`dbm` still defaults to `dbm.gnu` when it is installed.

For more information about Homebrew and Python, see: https://docs.brew.sh/Homebrew-and-Python

分析1:

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

这句话的意思,就是,如果你想要命令 python 启动 python3 、命令pip 启动 pip3,你需要把 /usr/local/opt/python@3.11/libexec/bin 放在你的 PATH 的开头。

我的是:

在终端执行命令:vim ~/.bash_profile
添加:

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

分析2:

You can install Python packages with
  pip3 install <package>
They will install into the site-package directory
  /usr/local/lib/python3.11/site-packages

这句话的意思就是,在使用命令pip3安装的包,存放的目录,在/usr/local/lib/python3.11/site-packages中。

分析3:

tkinter is no longer included with this formula, but it is available separately:
  brew install python-tk@3.11

gdbm (`dbm.gnu`) is no longer included in this formula, but it is available separately:
  brew install python-gdbm@3.11

这句话的意思是,tkinter 不再包含在formula中,但是可以独立使用它,brew install python-tk@3.11
同理gdbm,也是一样的。

分析4:

If you need to read a database from a previous Homebrew Python created via `dbm.ndbm`,
you'll need to read your database using the older version of Homebrew Python and convert to another format.
`dbm` still defaults to `dbm.gnu` when it is installed.

# 机器翻译
`dbm.ndbm` 在 Homebrew Python 3.11 中更改了数据库后端。

如果您需要从之前通过 dbm.ndbm 创建的 Homebrew Python 读取数据库,
您需要使用旧版本的 Homebrew Python 读取您的数据库并转换为另一种格式。
`dbm` 在安装时仍然默认为 `dbm.gnu`

总结

为了更好的管理,最好使用 Homebrew来安装,也就是执行brew install Python

参考地址:

How to Update Python on Mac Terminal

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

山鬼谣me

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值