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

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
T
Threatpost
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Spread Privacy
Spread Privacy
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Engineering at Meta
Engineering at Meta
T
Tenable Blog
C
Cisco Blogs
T
The Blog of Author Tim Ferriss
NISL@THU
NISL@THU
T
Threat Research - Cisco Blogs
T
The Exploit Database - CXSecurity.com
P
Privacy & Cybersecurity Law Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
S
Secure Thoughts
N
News and Events Feed by Topic
Google DeepMind News
Google DeepMind News
博客园 - 三生石上(FineUI控件)
Microsoft Azure Blog
Microsoft Azure Blog
月光博客
月光博客
H
Hacker News: Front Page
I
InfoQ
L
LangChain Blog
Security Latest
Security Latest
The Cloudflare Blog
Forbes - Security
Forbes - Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Stack Overflow Blog
Stack Overflow Blog
TaoSecurity Blog
TaoSecurity Blog
量子位
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
V
Visual Studio Blog
Scott Helme
Scott Helme
爱范儿
爱范儿
A
Arctic Wolf
F
Full Disclosure
酷 壳 – CoolShell
酷 壳 – CoolShell
Schneier on Security
Schneier on Security
N
News and Events Feed by Topic
C
CXSECURITY Database RSS Feed - CXSecurity.com
L
LINUX DO - 最新话题
V2EX - 技术
V2EX - 技术
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
人人都是产品经理
人人都是产品经理
The Hacker News
The Hacker News
Hugging Face - Blog
Hugging Face - Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
Know Your Adversary
Know Your Adversary
Application and Cybersecurity Blog
Application and Cybersecurity Blog

博客园 - 箫笛

Tkinter - Button 组件 Tkinter - Label 组件 Tkinter - tk 变量 Tkinter - 事件与绑定 Tkinter - 几何管理器 Tkinter - 核心概念 Tkinter - 快速开始 Tkinter - 介绍 Python 编程 - 条件表达式 Python 编程 - 星号下划线参数释义 shell 编程 - shell 脚本的交互方式 Miniconda - Python 环境管理工具 Tkinter - Python GUI 开发 Python 编程 - 下划线命名的区别 Python 编程 - 元类编程 Python 编程 - 多重继承与MRO Python 编程 - 描述符协议 Python 编程 - 类型注解 Python 编程 - 生成器表达式 Python 编程 - 集合 Python 编程 - 装饰器 Python 编程 - 闭包 Python 编程 - 列表推导式 Python 编程 - 函数式编程 Python 编程 - lambda 函数 Python 编程 - 文件操作 Python 编程 - 输入与输出 Python 编程 - 面向对象编程 Python 编程 - 元组(tuple) Python 编程 - 字符串(str) Python 编程 - 字典(dict) Python 编程 - 列表(list) Python 编程 - 数据类型和数据结构 Python 编程 - 语句 Python 编程 - 函数 windows - WSL 的安装与使用 shell编程 - dialog 程序使用指南 FE Team - 如何做好前端代码审查 git 提交的撤销和恢复 React15 - redux-saga 如何在saga中实现轮询接口调用? React15 - React CSS Modules BEM命名实践 React15 - React 15 中 componentWillReceiveProps 为什么会多次调用, 同时componentDidUpdate 也会多次调用? React15 - React15类组件多次执行render方法的原因? React15 - React15应用中代码逻辑复用方案 React15 - React状态同步问题解决 React15 - React 15 中 React.pureComponent 的使用场景 React15 - React 15应用在页面渲染时会多次执行类组件的render 函数的原因 React15 - React 15 中能用 componetDidUpdate 代替 componentWillReceiveProps 吗? React15 - React 15 生命周期函数详解 React15 - 如何在React 15中实现自定义的事件订阅与发送(例如组件间通信) React15 - React15应用中的事件订阅和发送机制 React15 - CSS中的BEM规范 React15 - React CSS Modules BEM命名实践 React15 - 写sass 样式文件,嵌套的结构好,还是扁平的结构好? React15 - sass 中 @mixin 和 @extend 的区别是什么? React15 - React 15 应用 如何使用Css moudules 方式进行模块化开发 React15 - React15应用Sass使用指南 React15 - React 15 应用如何进行性能优化?
Python insall - macOS 系统安装python的几种方式
箫笛 · 2026-07-05 · via 博客园 - 箫笛

在 macOS 上安装 Python,强烈不建议使用系统自带的版本(2.7 或旧版 3.x),因为系统内核依赖它,乱动会导致权限混乱或软件崩溃。

根据你的使用场景,以下四种主流方式,推荐直接看方案二或方案三

方案一:官网下载安装包(适合纯小白)

python.org 下载 macOS 版本的 .pkg 安装包,双击一路点“继续”即可。

  • 优点:图形化操作,最简单。
  • 缺点:权限管理较麻烦(经常需要 sudo),且无法方便地切换多版本。如果将来需要安装某些依赖系统库的包(如 lxml),可能会报错。

方案二:Homebrew 安装(最推荐,适合开发者)

Homebrew 是 macOS 的包管理器,安装的 Python 路径清晰,且与系统环境隔离,非常安全。

  1. 安装 Homebrew(若未安装):
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

  2. 安装 Python

    brew install python
    

    注意:Homebrew 默认安装的是最新的 Python 3.x。

  3. 验证

    python3 --version
    

    特别提醒:Homebrew 安装后,不会覆盖系统的 python 命令,你需要始终使用 python3pip3 来调用。


方案三:pyenv + Homebrew(最佳实践,管理多版本)

如果你未来可能需要同时使用 Python 3.11、3.12 或 3.13 进行项目测试,必须用这个方案。

  1. 先通过 Homebrew 安装 pyenv 和依赖:

    brew install pyenv openssl readline sqlite3 xz zlib tcl-tk
    
  2. 配置 Shell 环境(以 Zsh 为例),将以下内容加入 ~/.zshrc

    export PYENV_ROOT="$HOME/.pyenv"
    export PATH="$PYENV_ROOT/bin:$PATH"
    eval "$(pyenv init --path)"
    eval "$(pyenv init -)"
    

    然后执行 source ~/.zshrc 生效。

  3. 安装任意版本(例如安装 3.12.4):

    pyenv install 3.12.4
    
  4. 切换使用

    pyenv global 3.12.4  # 全局使用此版本
    python --version     # 此时 python 命令直接指向你指定的版本
    

方案四:Anaconda / Miniconda(适合数据科学/AI)

如果你主要做机器学习、数据分析,推荐安装 Miniconda(轻量级)。

  • Miniconda 官网 下载 .pkg.sh 安装。
  • 它的优势在于虚拟环境极其强大,且自带 conda install 可以绕过编译问题直接安装 numpypytorch 等大型库。

安装后的必做事项(避坑指南)

无论用哪种方式,装完后请立刻做这两件事:

  1. 区分 pip:如果系统里既有 pip 又有 pip3,请始终使用 pip3python -m pip,确保包装对了地方。
  2. 使用虚拟环境(重要):不要在全局 Base 环境里乱装包。请养成习惯:
    python3 -m venv my_project_env
    source my_project_env/bin/activate
    

总结建议

  • 只想写个简单脚本:选 方案二 (Homebrew),干净利落。
  • 正经搞开发或做项目:选 方案三 (pyenv),配合虚拟环境,未来切换版本只需一行命令。