惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Security Affairs
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
N
Netflix TechBlog - Medium
云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
A
About on SuperTechFans
Last Week in AI
Last Week in AI
博客园 - 叶小钗
博客园 - Franky
腾讯CDC
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
The GitHub Blog
The GitHub Blog
Google DeepMind News
Google DeepMind News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
小众软件
小众软件
The Hacker News
The Hacker News
C
Cisco Blogs
C
CXSECURITY Database RSS Feed - CXSecurity.com
L
LangChain Blog
WordPress大学
WordPress大学
美团技术团队
P
Proofpoint News Feed
T
Threat Research - Cisco Blogs
AWS News Blog
AWS News Blog
S
Securelist
T
Tenable Blog
I
Intezer
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
L
LINUX DO - 热门话题
博客园 - 三生石上(FineUI控件)
Y
Y Combinator Blog
Cisco Talos Blog
Cisco Talos Blog
T
Tor Project blog
Security Latest
Security Latest
Apple Machine Learning Research
Apple Machine Learning Research
C
Cybersecurity and Infrastructure Security Agency CISA
S
Schneier on Security
L
Lohrmann on Cybersecurity
P
Privacy & Cybersecurity Law Blog
月光博客
月光博客
P
Proofpoint News Feed
Vercel News
Vercel News
Simon Willison's Weblog
Simon Willison's Weblog
G
GRAHAM CLULEY
T
The Blog of Author Tim Ferriss
F
Fortinet All Blogs
博客园 - 【当耐特】
A
Arctic Wolf
aimingoo的专栏
aimingoo的专栏

轶哥博客

blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog blog
blog
2021-02-03 · via 轶哥博客

Homebrew是MacOS中绝佳的包管理工具。通过brew安装pyton3非常容易brew install python@3,将会自动添加python3pip3命令。

关于python的安装,在Homebrew官网给出了详细的说明:https://docs.brew.sh/Homebrew-and-Python

Homebrew provided a python@2 formula until the end of 2019, at which point it was removed due to the Python 2 deprecation.

根据提示,我们知道python@2已经被移除。在2020年初,python@2仍然可以正常安装,但就在不久前,官方移除了python@2。我对Homebrew官方的操作表示支持和理解,毕竟技术的更新和迭代是不可逆转的,是需要大家一起支持的。

Python官方宣布 2020 年 1 月后不再更新维护 Python2,然而由于历史原因以及各国生态差异,某些情况下不得不再次安装python2。即使距离python3最初版本发布已经超过10年,仍然有很多项目依赖python2(这里没有吐槽的意思,但JavaScript生态必须感谢babel)。

brew安装python2的方式:

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

安装python2是不被推荐的。

其它说明

  1. 通过brew extract安装python2的方式已经失效了,参见
  2. 上述安装方法参考自:https://stackoverflow.com/questions/60298514/how-to-reinstall-python2-from-homebrew
  3. 在M1芯片的Mac设备上,此安装方式不适用于原生支持 ARM 架构的Homebrew实验性版本。需要安装Rosetta加持的X86版本Homebrew,然后使用上述方法进行安装。
  4. 如果上述wget命令执行失败,有可能是网络原因导致的。可以考虑使用 https://cdn.wyr.me/files/2021-02-03/python@2.rb 地址代替。

M1芯片使用Intel版本Homebrew

来自 https://stackoverflow.com/questions/64963370/error-cannot-install-in-homebrew-on-arm-processor-in-intel-default-prefix-usr

For what it's worth, before installing Homebrew you will need to install Rosetta2 emulator for the new ARM silicon (M1 chip). I just installed Rosetta2 via terminal using:

/usr/sbin/softwareupdate --install-rosetta --agree-to-license

This will install rosetta2 with no extra button clicks.

After installing Rosetta2 above you can then use the Homebrew cmd and install Homebrew for ARM M1 chip: arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Once Homebrew for M1 ARM is installed use this Homebrew command to install packages: arch -x86_64 brew install <package>

特别提示

从MacOS 12.3 Beta版本开始,Apple不再内置python2且将无法正常安装python2,无论是intel芯片还是Apple芯片的设备都无法安装。原因是/usr/bin/python的软链接无法正常被删除或覆盖。

2022年04月17日14:02:24更新: 从MacOS 12.4 Beta版(21F5048e) 开始,可以通过pyenv在intel和Apple芯片中安装python2。

例如在M1中安装 2.7.18 版本的 python2。

brew install pyenv
pyenv install 2.7.18
export PATH="$(pyenv root)/shims:${PATH}"
pyenv global 2.7.18
python --version

如果一切顺利,将可以看到Python 2.8.18的输出。

需要将上述路径添加到环境变量里面,例如:

echo 'PATH=$(pyenv root)/shims:$PATH' >> ~/.zshrc

此方法可以与brew install python3方式安装的python3共存。

如果遇到VS(Visual Studio Code)无法使用code命令,可以参阅博文:《MacOS 12.3 无法正常使用code命令的解决方法》