首页 > 解决方案 > 在 macOS 上使用 pyenv 安装 python 3.8 失败

问题描述

安装 python 3.8.8pyenv失败。

安装失败如下:

$pyenv install 3.8.8
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.8.8.tar.xz...
-> https://www.python.org/ftp/python/3.8.8/Python-3.8.8.tar.xz
Installing Python-3.8.8...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk

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

Inspect or clean up the working tree at /var/folders/d6/m67jyndd7h754m3810cl3bpm0000gp/T/python-build.20210323082704.55952
Results logged to /var/folders/d6/m67jyndd7h754m3810cl3bpm0000gp/T/python-build.20210323082704.55952.log

Last 10 log lines:
checking for python3.8... no
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/d6/m67jyndd7h754m3810cl3bpm0000gp/T/python-build.20210323082704.55952/Python-3.8.8':
configure: error: C compiler cannot create executables
See `config.log' for more details

我在安装了最新的xcode的Catalina

$/usr/bin/xcodebuild -version
Xcode 12.4
Build version 12D4e

gcc看起来很合理:

$which gcc
/usr/bin/gcc

$gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

以下是有关信息clang

$which clang
/usr/bin/clang
09:17:36/Python-3.8.8 $clang -v
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

更新这里有一些错误config.log:有关于clang的投诉:

configure:3869: clang -V >&5
clang: error: argument to '-V' is missing (expected 1 value)
clang: error: no input files
configure:3880: $? = 1
configure:3869: clang -qversion >&5
clang: error: unknown argument '-qversion'; did you mean '--version'?
clang: error: no input files

...

configure:3922: clang -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk  -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/Users/steve/.pyenv/versions/3.8.8/include -I/usr/local/opt/openssl@1.1/include-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -L/usr/local/opt/readline/lib -L/usr/local/opt/readline/lib -L/Users/steve/.pyenv/versions/3.8.8/lib -L/usr/local/opt/openssl@1.1/lib conftest.c  >&5
clang: warning: no such sysroot directory: '/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk-isysroot' [-Wmissing-sysroot]
ld: warning: directory not found for option '-L/opt/local/lib'
ld: can't map file, errno=22 file '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

请注意,我已经查看了PyEnv BUILD FAILED installed Python on MacOS的答案。例如,我尝试了以下操作:

export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
export MACOSX_DEPLOYMENT_TARGET=10.15
pyenv install 3.8.8

但它以同样的方式失败了。我还应该检查什么以及如何解决?

标签: pythonpyenv

解决方案


推荐阅读