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

MacOS下用PyEnv安装旧版Python(如3.6.14)编译失败求助

解决MacOS下PyEnv安装Python 3.6.14失败的BUILD FAILED错误

核心问题分析

错误日志显示checking for clang++... no以及configure: error: internal configure error for the platform triplet,本质是旧版Python(3.6.x)无法适配MacOS Monterey的新编译器和SDK环境,导致配置阶段无法识别平台信息。

解决方案步骤

1. 明确指定编译器及SDK路径

旧版Python需要手动指定编译器和SDK路径才能完成配置,执行以下命令安装:

SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk \
CC=clang \
CXX=clang++ \
pyenv install 3.6.14
  • 若你的Xcode对应不同版本的SDK,可通过ls /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/查看可用SDK路径并替换。
  • 若clang++未找到,先重新安装Xcode命令行工具:xcode-select --install

2. 应用适配Monterey的补丁

如果上述命令仍失败,需给Python 3.6.14打补丁以支持MacOS Monterey的平台识别:

  1. 创建补丁文件python36-monterey.patch,内容如下:
diff --git a/configure b/configure
index 9f9e01b..d2d80b3 100755
--- a/configure
+++ b/configure
@@ -11161,7 +11161,7 @@ $as_echo "#define __APPLE_USE_RFC_3542 1" >>confdefs.h
 
 
     case $host_os in
-        darwin1[0-9].*)
+        darwin1[0-9].* | darwin2[0-2].*)
             # macOS 10.6+ has RFC 3542 sockaddr_storage
             ac_cv_func_getaddrinfo=yes
             ;;
diff --git a/configure.ac b/configure.ac
index 7a1b3d4..8b7a6d0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -623,7 +623,7 @@ AC_CHECK_FUNCS(getaddrinfo)
     case $host_os in
         darwin*)
             # macOS 10.6+ has RFC 3542 sockaddr_storage
-            darwin1[0-9].*)
+            darwin1[0-9].* | darwin2[0-2].*)
                 ac_cv_func_getaddrinfo=yes
                 ;;
         esac
  1. 执行带补丁的安装命令:
SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk \
CC=clang \
CXX=clang++ \
pyenv install 3.6.14 --patch < python36-monterey.patch

3. 确保依赖库完整安装

通过Homebrew安装Python编译所需的依赖:

brew install openssl readline xz zlib

若仍有依赖相关问题,可在安装命令中添加依赖路径:

CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix readline)/include -I$(brew --prefix xz)/include -I$(brew --prefix zlib)/include" \
LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix xz)/lib -L$(brew --prefix zlib)/lib" \
SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk \
CC=clang \
CXX=clang++ \
pyenv install 3.6.14 --patch < python36-monterey.patch

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.20 00:25:28