如何使用自制软件在 macOS 中安装以前版本的 Python 3? [英] How can I install a previous version of Python 3 in macOS using homebrew?

查看:17
本文介绍了如何使用自制软件在 macOS 中安装以前版本的 Python 3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 brew 在 macOS 中安装以前版本的 Python 3?

How can I install a previous version of Python 3 in macOS using brew?

使用命令 brew install python 我获得了 Python 3 的最新版本(当前为 v3.7.0),但我想要 Python 3.6 的最新版本(当前为 3.6.5).

With the command brew install python I got the latest version of Python 3 (currently v3.7.0), but I want the last version of Python 3.6 (currently 3.6.5).

我读过另一个包 pyenv 可以帮助处理不同的 python 安装,但这个解决方案不适合我.

I have read about another package pyenv that can assist in handle different python installation, but this solution is not suitable for me.

推荐答案

简答

要全新安装 Python 3.6.5,请使用:

Short Answer

To make a clean install of Python 3.6.5 use:

brew unlink python # ONLY if you have installed (with brew) another version of python 3
brew install --ignore-dependencies https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb

如果您希望恢复以前安装的版本,则:

If you prefer to recover a previously installed version, then:

brew info python           # To see what you have previously installed
brew switch python 3.x.x_x # Ex. 3.6.5_1

长答案

使用 Homebrew 安装 Python 有两个公式:python@2python.
第一个用于 Python 2,第二个用于 Python 3.

Long Answer

There are two formulas for installing Python with Homebrew: python@2 and python.
The first is for Python 2 and the second for Python 3.

注意:您可以在网络上找到过时的答案,其中提到 python3 作为安装 Python 版本 3 的公式名称.现在它只是 python!

Note: You can find outdated answers on the web where it is mentioned python3 as the formula name for installing Python version 3. Now it's just python!

默认情况下,您可以使用这些公式安装相应主要 Python 版本的最新版本.所以,你不能直接安装像3.6这样的次要版本.

By default, with these formulas you can install the latest version of the corresponding major version of Python. So, you cannot directly install a minor version like 3.6.

使用 brew,您可以使用公式的地址安装包,例如在 git 存储库中.

With brew, you can install a package using the address of the formula, for example in a git repository.

brew install https://the/address/to/the/formula/FORMULA_NAME.rb

或者专门针对 Python 3

Or specifically for Python 3

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/COMMIT_IDENTIFIER/Formula/python.rb

您必须指定的地址是所需版本的公式 (python.rb) 最后一次提交的地址.您可以通过查看 homebrew-core/Formula/python.rb 的历史记录来找到 commint 标识符

The address you must specify is the address to the last commit of the formula (python.rb) for the desired version. You can find the commint identifier by looking at the history for homebrew-core/Formula/python.rb

https://github.com/Homebrew/homebrew-core/commits/master/Formula/python.rb

在上面的链接中,您找不到适用于 3.6.5 以上 Python 版本的公式.在该(官方)存储库的维护者发布 Python 3.7 后,他们只提交对 Python 3.7 配方的更新.

In the link above you will not find a formula for a version of Python above 3.6.5. After the maintainers of that (official) repository released Python 3.7, they only submit updates to the recipe of Python 3.7.

如上所述,对于自制软件,您只有 Python 2 (python@2) 和 Python 3 (python),Python 3.6 没有明确的公式.

As explained above, with homebrew you have only Python 2 (python@2) and Python 3 (python), there is no explicit formula for Python 3.6.

尽管在大多数情况下,对于大多数用户来说,这些小更新大多无关紧要,但我会搜索是否有人为 3.6 制定了明确的公式.

Although those minor updates are mostly irrelevant in most cases and for most users, I will search if someone has done an explicit formula for 3.6.

这篇关于如何使用自制软件在 macOS 中安装以前版本的 Python 3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆