pyenv笔记


常见问题

pyenv install 3.6.7 失败

  • 环境: macOs big Sur 11.2.2

  • pyenv: 1.2.23

相关日志

┌─[jianglin][~/repo/golang/src/alarm](master)
└──╼ pyenv install 3.6.7
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Installing Python-3.6.7...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk

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

Inspect or clean up the working tree at /var/folders/44/hnrgfyfn0fsb8lqwk_0h2jvm0000gn/T/python-build.20210318151243.78376
Results logged to /var/folders/44/hnrgfyfn0fsb8lqwk_0h2jvm0000gn/T/python-build.20210318151243.78376.log

Last 10 log lines:
        ret = sendfile(in, out, offset, &sbytes, &sf, flags);
              ^
./Modules/posixmodule.c:10433: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/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include   -I/Library/Developer/CommandLineTools/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/jianglin/repo/python/pyenv/versions/3.6.7/include  -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl@1.1/include -I/Users/jianglin/repo/python/pyenv/versions/3.6.7/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.
┌─[jianglin][~/repo/golang/src/alarm](master)
└──╼  pyenv install --patch 3.6.7 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Installing Python-3.6.7...
curl: (28) Operation timed out after 300188 milliseconds with 0 out of 0 bytes received
python-build: use readline from homebrew
python-build: use zlib from xcode sdk

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

Inspect or clean up the working tree at /var/folders/44/hnrgfyfn0fsb8lqwk_0h2jvm0000gn/T/python-build.20210318151644.86904
Results logged to /var/folders/44/hnrgfyfn0fsb8lqwk_0h2jvm0000gn/T/python-build.20210318151644.86904.log

Last 10 log lines:
./Modules/posixmodule.c:8211:15: error: implicit declaration of function 'sendfile' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        ret = sendfile(in, out, offset, &sbytes, &sf, flags);
              ^
./Modules/posixmodule.c:10433:5: warning: code will never be executed [-Wunreachable-code]
    Py_FatalError("abort() called from Python code didn't abort!");
    ^~~~~~~~~~~~~
1 warning and 1 error generated.
make: *** [Modules/posixmodule.o] Error 1
make: *** Waiting for unfinished jobs....
1 warning generated.

解决方式

┌─[jianglin][~/repo/golang/src/alarm](master)
└──╼ CFLAGS=-Wno-implicit-function-declaration  pyenv install --patch 3.6.7 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Installing Python-3.6.7...
curl: (7) Failed to connect to github.com port 443: Operation timed out
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.6.7 to /Users/jianglin/repo/python/pyenv/versions/3.6.7

参考文档

  • https://github.com/pyenv/pyenv/issues/1737

  • https://github.com/pyenv/pyenv/issues/1643

作者: honmaple
链接: https://honmaple.me/articles/2021/03/pyenv笔记.html
版权: 知识共享署名-非商业性使用-相同方式共享4.0国际许可协议
wechat