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

在MacOS Sonoma中使用pyenv安装Python3.6.8失败求助

在Mac OS X 14.3.1上安装Python 3.6.8的问题解决方法

问题描述

pyenv安装失败报错

尝试用pyenv安装Python 3.6.8时出现以下构建错误:

BUILD FAILED (OS X 14.3.1 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/12/9cwdctlj7hs4g9w160xyg6rr0000gn/T/python-build.20240301183819.4919
Results logged to /var/folders/12/9cwdctlj7hs4g9w160xyg6rr0000gn/T/python-build.20240301183819.4919.log

Last 10 log lines:
checking for long double support... yes
checking size of long double... 8
checking size of _Bool... 1
checking size of off_t... 8
checking whether to enable large file support... no
checking size of time_t... 8
checking for pthread_t... yes
checking size of pthread_t... 8
configure: error: Unexpected output of 'arch' on OSX
make: *** No targets specified and no makefile found.  Stop.

Homebrew安装失败报错

使用brew安装时提示:

No available formula with the name "python@3.6". Did you mean python@3.9, python@3.8, python@3.7, python@3.12, python@3.11, python@3.10 or python-yq?

解决方案

修复pyenv安装错误

  1. 更新pyenv
    你的python-build版本过于老旧,先更新pyenv:

    brew upgrade pyenv
    

    若通过git克隆安装pyenv,执行:

    cd $(pyenv root) && git pull
    
  2. 指定x86_64架构安装
    Python 3.6.8不支持Apple Silicon的arm64架构,需强制使用x86_64架构:

    arch -x86_64 pyenv install 3.6.8
    

    或先设置环境变量再安装:

    export ARCHFLAGS="-arch x86_64"
    pyenv install 3.6.8
    
  3. 安装依赖库(若仍失败)
    Python 3.6.8需要旧版本OpenSSL,先安装对应依赖:

    brew install openssl@1.1
    

    然后指定OpenSSL路径安装:

    PYTHON_CONFIGURE_OPTS="--with-openssl=$(brew --prefix openssl@1.1)" arch -x86_64 pyenv install 3.6.8
    
  4. 确保安装Xcode命令行工具
    若未安装,执行:

    xcode-select --install
    

修复Homebrew安装错误

Homebrew官方已移除Python 3.6的公式(Python 3.6已停止维护),优先使用上述pyenv方法安装。若坚持用brew,可尝试添加第三方tap(稳定性无法保证):

brew tap homebrew/cask-versions
brew install python@3.6

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.29 02:14:52