当前位置:   article > 正文

MacBookPro 安装Python_macbookpro2023怎么下载python

macbookpro2023怎么下载python

Homebrew

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

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

安装Python

执行命令:

yutao@MacBook-Pro Homebrew % brew install Python
  • 1

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

执行命令:

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

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

然后再次执行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
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24

分析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
  • 1
  • 2
  • 3

这句话的意思,就是,如果你想要命令 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"
  • 1

分析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
  • 1
  • 2
  • 3
  • 4

这句话的意思就是,在使用命令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
  • 1
  • 2
  • 3
  • 4
  • 5

这句话的意思是,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`
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

总结

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

参考地址:

How to Update Python on Mac Terminal

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/人工智能uu/article/detail/899347
推荐阅读
相关标签
  

闽ICP备14008679号