Pyenv 不会在 Mac os 11 上安装 python 3

jas*_*onm 18 pyenv

尝试在 Mac OS 11.0.1 上使用 pyenv install 3.9.0.

结果:

python-build: use readline from homebrew
Downloading Python-3.9.0.tar.xz...
-> https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tar.xz
Installing Python-3.9.0...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk

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

Inspect or clean up the working tree at /var/folders/n6/q2b78971589bltfczw539flh0000gn/T/python-build.20201114175722.7103
Results logged to /var/folders/n6/q2b78971589bltfczw539flh0000gn/T/python-build.20201114175722.7103.log

Last 10 log lines:
checking for python3... python3
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... "darwin"
checking for gcc... clang
checking whether the C compiler works... no
configure: error: in `/var/folders/n6/q2b78971589bltfczw539flh0000gn/T/python-build.20201114175722.7103/Python-3.9.0':
configure: error: C compiler cannot create executables
See `config.log' for more details
make: *** No targets specified and no makefile found.  Stop.
Run Code Online (Sandbox Code Playgroud)

类似问题中的许多建议似乎都围绕 XCode,但xcode-select --install表示已经安装了命令行工具。

任何帮助表示赞赏。

Cor*_*ius 20

我今天遇到了同样的问题,并在深入了解config.log在此处查看了这篇文章后设法更进一步。

sudo xcode-select --switch /Applications/Xcode.app/从 App Store 下载 Xcode 后,我不得不采取相反的方向并执行。如果你运行clang --version它应该显示Apple clang version 12.0.0 (clang-1200.0.32.27).

我能够执行pyenv install 3.9.0并克服C compiler cannot create executables错误,但不幸的是它仍然失败。config.log这次很大,看看我能不能找到什么。

编辑:我通过执行以下命令(包括在此处找到的补丁)设法安装了 3.8.0 。

CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include" LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib" pyenv install --patch 3.8.0 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)
Run Code Online (Sandbox Code Playgroud)

有一些 macOS 11.0 合并,但我认为用于该pyenv install命令的存储库尚未更新。但是,此解决方法足以满足我现在的需求。