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

MacOS Big Sur下pyenv与poetry安装问题:pyenv install 3.9.0编译失败求助

Fixing pyenv install 3.9.0 Failure on Big Sur (C Compiler Error)

It sounds like your C compiler is hitting a roadblock during the Python build process, even with Xcode Command Line Tools installed. Let’s work through targeted fixes tailored for Big Sur:

Step 1: Ensure Xcode Command Line Tools are fully configured

Even if you’ve installed the tools, they might need a reset or license acceptance to work properly:

  • Refresh the command line tools (this won’t overwrite existing installs):
    xcode-select --install
    
  • Accept the Xcode license agreement (required for compiler functionality):
    sudo xcodebuild -license accept
    
  • Reset the tools path to avoid conflicts with a full Xcode installation (if you have it):
    sudo xcode-select -s /Library/Developer/CommandLineTools
    

Step 2: Update critical Homebrew dependencies

Python builds rely on Homebrew versions of openssl, readline, and zlib. Make sure these are up to date:

brew update && brew upgrade openssl@1.1 readline zlib

Big Sur changes how system libraries are accessed, so we need to point the build to Homebrew’s versions directly:

export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/zlib/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/zlib/include"
export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"

Then run the install command again:

pyenv install 3.9.0

Step 4: Clean up leftover build artifacts

The failed build left temporary files that could cause issues. Delete the working directory mentioned in your error:

rm -rf /var/folders/_3/3n7g_jr918v2cj_pkdlfk5t40000gn/T/python-build.20210619130847.19436

Step 5: Debug with verbose output

If the above steps don’t resolve the issue, run the install in verbose mode to get detailed logs of where the compiler is failing:

pyenv install -v 3.9.0

This will show you exactly which step is breaking, helping pinpoint missing dependencies or configuration gaps.

Quick sanity check: Verify your pyenv setup is loaded correctly by running:

echo $PYENV_ROOT && echo $PATH | grep pyenv

You should see $HOME/.pyenv and the pyenv bin directory in your PATH.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.29 19:52:39