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

查看:109
本文介绍了如何使用自制软件在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

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天全站免登陆