如何解决在具有Intel芯片和Big Sur的MacBook Pro上安装Python < 3.7时出现的`pyenv`问题?

4

pyenv 在搭载 Intel 芯片和 Big Sur 操作系统的 MacBook 上存在问题。

以下为我的系统信息:

$ brew --version
3.2.2

$ brew list
==> Formulae
autoconf    gdbm        mpdecimal   pkg-config  python@3.9  sqlite      xz
bzip2       m4      openssl@1.1 pyenv       readline    tcl-tk      zlib

$ xcodebuild -version
Xcode 12.5.1
Build version 12E507

$ xcode-select -version
xcode-select version 2384.

$ sw_vers
ProductName:    macOS
ProductVersion: 11.4
BuildVersion:   20F71

尝试安装不同版本的pyenv时会发生以下情况:

$ pyenv install 3.9.6   # Success
$ pyenv install 3.8.11  # Success
$ pyenv install 3.7.11  # Success
$ pyenv install 3.6.14  # Error
python-build: use readline from homebrew
python-build: use zlib from xcode sdk

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

Inspect or clean up the working tree at /var/folders/qr/wfhlfnfs62g7lf56wpk1ffp80000gp/T/python-build.20210715170801.48468
Results logged to /var/folders/qr/wfhlfnfs62g7lf56wpk1ffp80000gp/T/python-build.20210715170801.48468.log

Last 10 log lines:
        ret = sendfile(in, out, offset, &sbytes, &sf, flags);
              ^
./Modules/posixmodule.c:10432:5: warning: code will never be executed [-Wunreachable-code]
    Py_FatalError("abort() called from Python code didn't abort!");
    ^~~~~~~~~~~~~
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include   -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include   -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes   -I. -I./Include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl@1.1/include -I/Users/ranjan.lamichhane/.pyenv/versions/3.6.14/include -I/usr/local/opt/zlib/include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl@1.1/include -I/Users/ranjan.lamichhane/.pyenv/versions/3.6.14/include -I/usr/local/opt/zlib/include  -DPy_BUILD_CORE  -c ./Modules/pwdmodule.c -o Modules/pwdmodule.o
1 warning and 1 error generated.
make: *** [Modules/posixmodule.o] Error 1
make: *** Waiting for unfinished jobs....
1 warning generated.

我尝试使用一些在GitHub问题讨论中找到的建议来修复它,但似乎都没有起作用。


rrlamichhane,有什么进展吗?虽然我的构建是最新更新的,但我也遇到了同样的问题。我尝试了所有我找到的建议,但似乎没有任何作用。 - Higor Rossato
1
很遗憾,我还没有找到任何解决方案。我一直在使用Python版本> 3.7。 - rrlamichhane
1个回答

0

我在使用brew和pyenv安装Python 3.7.6时遇到了同样的问题。 运行以下命令解决了这个问题: 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.7.6 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接