You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

macOS系统下新版本发布时,如何更新已安装的Python 3.6.5?

Hey there! Since you're running macOS with Python 3.6.5 already, let's walk through the most reliable ways to update to a newer Python version—no messy system overrides, promise:

方法1:官方安装包(最简单直接)

If you want a no-fuss, straightforward update, go with the official Python installer:

  • Head to the official Python website and download the latest stable release's .pkg installer.
  • Open the downloaded file and follow the installation wizard. By default, it’ll install the new version in /Library/Frameworks/Python.framework/Versions/.
  • After installation, check your current Python version with python3 --version. If it still shows 3.6.5, you’ll need to add the new version to your system path:
    1. Open your shell config file (either ~/.zshrc for Zsh or ~/.bash_profile for Bash) in a text editor.
    2. Add this line, replacing [NEW_VERSION] with the actual version number (like 3.12):
      export PATH="/Library/Frameworks/Python.framework/Versions/[NEW_VERSION]/bin:$PATH"
      
    3. Save the file, then run source ~/.zshrc (or source ~/.bash_profile) to apply the changes. Now python3 --version should show the new version.
方法2:Homebrew更新(适合已用Homebrew的用户)

If you already use Homebrew for package management, this is super smooth:

  • First, make sure Homebrew is up to date:
    brew update
    
  • Install the latest Python release:
    brew install python
    
  • Homebrew will automatically set the new Python version as your default. Verify with python3 --version.
  • If you have old Python versions lingering, clean them up with:
    brew cleanup python
    
方法3:pyenv(推荐管理多版本)

If you need to switch between multiple Python versions (like keeping 3.6.5 for old projects and using a new version for others), pyenv is your best bet—it keeps versions isolated so you don’t mess up your system or existing projects:

  • Install pyenv via Homebrew:
    brew install pyenv
    
  • Configure your shell to use pyenv. Open your ~/.zshrc or ~/.bash_profile and add these lines:
    export PYENV_ROOT="$HOME/.pyenv"
    command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
    eval "$(pyenv init -)"
    
  • Save the file and run source ~/.zshrc (or your respective config file) to activate the changes.
  • List all available Python versions you can install:
    pyenv install --list
    
  • Install the version you want (replace 3.12.0 with your target version):
    pyenv install 3.12.0
    
  • Set the new version as your global default:
    pyenv global 3.12.0
    
  • Verify with python --version (pyenv makes python point to your selected version now).

Quick Notes:

  • Never mess with the system Python: macOS relies on its built-in Python version for system tools. All methods above install separate, independent Python versions so you won’t break your OS.
  • When using pip, the new Python version will have its own pip (usually pip3). Run pip3 install [package-name] to install packages for the new version.

内容的提问来源于stack exchange,提问作者berkb

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 08:02:18