V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
GTD
V2EX  ›  macOS

Pyenv 编译失败,有没有大佬知道怎么解决?

  •  
  •   GTD · 2020-12-05 23:07:31 +08:00 · 1465 次点击
    这是一个创建于 1449 天前的主题,其中的信息可能已经有所发展或是发生改变。

    Pyenv 用

    brew install pyenv
    

    安装好后

    然后

    pyenv install 3.9.0
    

    报错如图:

    尝试 head 版本,依然报错

    以前用 catalina 没这问题,升级 big sur 后一直编译失败,尝试 3.7.6

    $ pyenv install 3.7.6
    python-build: use [email protected] from homebrew
    python-build: use readline from homebrew
    Downloading Python-3.7.6.tar.xz...
    -> https://www.python.org/ftp/python/3.7.6/Python-3.7.6.tar.xz
    Installing Python-3.7.6...
    python-build: use readline from homebrew
    python-build: use zlib from xcode sdk
    
    BUILD FAILED (OS X 11.0 using python-build 20180424)
    
    Inspect or clean up the working tree at /var/folders/gj/x6v5vwdx1v7741fdfcxwmr100000gn/T/python-build.20200830033458.15319
    Results logged to /var/folders/gj/x6v5vwdx1v7741fdfcxwmr100000gn/T/python-build.20200830033458.15319.log
    
    Last 10 log lines:
        struct sf_hdtr sf;
               ^
    ./Modules/posixmodule.c:8401:15: error: implicit declaration of function 'sendfile' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
            ret = sendfile(in, out, offset, &sbytes, &sf, flags);
                  ^
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include   -I/Applications/Xcode-beta.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 -Werror=implicit-function-declaration   -I. -I./Include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/Users/koji/.pyenv/versions/3.7.6/include  -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/Users/koji/.pyenv/versions/3.7.6/include    -c ./Modules/pwdmodule.c -o Modules/pwdmodule.o
    2 errors generated.
    make: *** [Modules/posixmodule.o] Error 1
    make: *** Waiting for unfinished jobs....
    1 warning generated.
    

    尝试重新安装 zlib

    $ brew install zlib
    $ export LDFLAGS="-L/usr/local/opt/zlib/lib" 
    $ export CPPFLAGS="-I/usr/local/opt/zlib/include
    

    依然报错。

    尝试直接 brew 安装 Python 3.9,成功。说明编译工具没问题,是 pyenv 的问题,目前有大佬知道怎么解决吗? pyenv 对我来说蛮重要的

    dylan
        1
    dylan  
       2021-01-23 10:36:59 +08:00
    这个版本的 pyenv 不支持,现在支持了,brew reinstall pyenv 一下
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2433 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 02:21 · PVG 10:21 · LAX 18:21 · JFK 21:21
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.