在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安装错误
更新pyenv
你的python-build版本过于老旧,先更新pyenv:brew upgrade pyenv若通过git克隆安装pyenv,执行:
cd $(pyenv root) && git pull指定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安装依赖库(若仍失败)
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确保安装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
相关产品推荐
相关产品推荐

