Brew-重新安装python @ 2


14

我在brew上遇到openssl和python @ 2的问题,这里已经解释了(未解决)。已记录的重新安装Python和openssl的解决方法无法正常工作,因此我决定卸载并重新安装Python。

问题是,当您尝试通过brew安装Python 2时,会收到以下消息:

brew install python@2
Error: No available formula with the name "python@2"
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
  git -C "$(brew --repo homebrew/core)" fetch --unshallow

python@2 was deleted from homebrew/core in commit 028f11f9e:
  python@2: delete (https://github.com/Homebrew/homebrew-core/issues/49796)
  EOL 1 January 2020.
  We gave it 1 month more to live so that people had time to migrate.
  All in all, developers had 11 years to do their migration.
  You can use the `brew extract` command and maintain python@2 in your own
  tap if necessary:
  https://docs.brew.sh/How-to-Create-and-Maintain-a-Tap

To show the formula before removal run:
  git -C "$(brew --repo homebrew/core)" show 028f11f9e^:Formula/python@2.rb

If you still use this formula consider creating your own tap:
  https://docs.brew.sh/How-to-Create-and-Maintain-a-Tap

不幸的是,我仍然有许多取决于Brew的python @ 2的brew公式。这些包括awscliletsencrypt,PR sshuttle例如

aws
zsh: /usr/local/bin/aws: bad interpreter: /usr/local/opt/python@2/bin/python2.7: no such file or directory

我不知道如何使用brew extract他们记录的命令重新安装Python @ 2。它需要一个公式和一个水龙头。我想公式会是python@2。我不确定水龙头将是什么。

此外,重新安装水龙头,例如awsletsencrypt效果也不佳。

重新安装awsclibrew reinstall awscli)后,运行aws命令仍然会出现错误。

aws
/usr/local/Cellar/awscli/2.0.0/libexec/lib/python3.8/site-packages/jmespath/visitor.py:32: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if x is 0 or x is 1:
/usr/local/Cellar/awscli/2.0.0/libexec/lib/python3.8/site-packages/jmespath/visitor.py:32: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if x is 0 or x is 1:
/usr/local/Cellar/awscli/2.0.0/libexec/lib/python3.8/site-packages/jmespath/visitor.py:34: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif y is 0 or y is 1:
/usr/local/Cellar/awscli/2.0.0/libexec/lib/python3.8/site-packages/jmespath/visitor.py:34: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif y is 0 or y is 1:
/usr/local/Cellar/awscli/2.0.0/libexec/lib/python3.8/site-packages/jmespath/visitor.py:260: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if original_result is 0:
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

  aws help
  aws <command> help
  aws <command> <subcommand> help
aws: error: the following arguments are required: command

Answers:


54

看来,自制软件的工作人员确实使尽可能多地在macOS上使用Python 2.7变得非常困难。

  1. 链接的brew extract链接确实没有帮助,您需要在此处查找有关如何从提取的资源中进行自己的点击的答案。
  2. 链接的提交:028f11f9e错误,因为它包含已删除的文件。
  3. 由于包名称中的@,该brew extract命令甚至无法正常工作

但是,该解决方案非常简单,您只需要从已知的最新提交进行安装:

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/86a44a0a552c673a05f11018459c9f5faae3becc/Formula/python@2.rb

有人警告说这是“不稳定”的,我不理解,因为在Git历史记录中的提交是尽可能稳定的。


1
只需在此处放置指向PR的链接,即可删除python @ 2(于2020年2月4日合并)github.com/Homebrew/homebrew-core/pull/49796
petschki

@petschki不是我们要求的答案,而是我们想知道的答案!
ThinkBonobo
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.