代码之家  ›  专栏  ›  技术社区  ›  brandonscript

安装3.5.6、3.6.7时,Mojave上的pyenv抛出未声明的标识符“CLOCK_REALTIME”和其他错误

  •  6
  • brandonscript  · 技术社区  · 7 年前

    10.14.2 Beta (18C52a) .

    3.6.7出现以下故障:

    python-build: use openssl from homebrew
    python-build: use readline from homebrew
    Downloading Python-3.6.7.tar.xz...
    -> https://www.python.org/ftp/python/3.6.7/Python-3.6.7.tar.xz
    Installing Python-3.6.7...
    python-build: use readline from homebrew
    
    BUILD FAILED (OS X 10.14.2 using python-build 20180424)
    
    Inspect or clean up the working tree at /var/folders/db/pjnyydt54kl3_snfwpvlsxf40000gp/T/python-build.20181204115752.83999
    Results logged to /var/folders/db/pjnyydt54kl3_snfwpvlsxf40000gp/T/python-build.20181204115752.83999.log
    
    Last 10 log lines:
    ./Include/pytime.h:200:52: warning: declaration of 'struct tm' will not be visible outside of this function [-Wvisibility]
    PyAPI_FUNC(int) _PyTime_localtime(time_t t, struct tm *tm);
                                                       ^
    ./Include/pytime.h:204:49: warning: declaration of 'struct tm' will not be visible outside of this function [-Wvisibility]
    PyAPI_FUNC(int) _PyTime_gmtime(time_t t, struct tm *tm);
                                                    ^
    2 warnings generated.
    2 warnings generated.
    2 warnings generated.
    2 warnings generated.
    

    3.5.6出现以下故障:

    python-build: use openssl from homebrew
    python-build: use readline from homebrew
    Downloading Python-3.5.6.tar.xz...
    -> https://www.python.org/ftp/python/3.5.6/Python-3.5.6.tar.xz
    Installing Python-3.5.6...
    python-build: use readline from homebrew
    
    BUILD FAILED (OS X 10.14.2 using python-build 20180424)
    
    Inspect or clean up the working tree at /var/folders/db/pjnyydt54kl3_snfwpvlsxf40000gp/T/python-build.20181204115931.92145
    Results logged to /var/folders/db/pjnyydt54kl3_snfwpvlsxf40000gp/T/python-build.20181204115931.92145.log
    
    Last 10 log lines:
    Python/pytime.c:508:13: warning: implicit declaration of function 'clock_getres' is invalid in C99 [-Wimplicit-function-declaration]
            if (clock_getres(CLOCK_REALTIME, &res) == 0)
                ^
    Python/pytime.c:508:13: warning: this function declaration is not a prototype [-Wstrict-prototypes]
    Python/pytime.c:508:26: error: use of undeclared identifier 'CLOCK_REALTIME'
            if (clock_getres(CLOCK_REALTIME, &res) == 0)
                             ^
    4 warnings and 2 errors generated.
    make: *** [Python/pytime.o] Error 1
    make: *** Waiting for unfinished jobs....
    

    我已经试过了 brew :

    1. pyenv , python , python3 , xz , readline openssl (根据 this answer
    2. 我试过了 sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target / (根据pyenv文件)
    3. 10.14.1 (18B75) ,我也有同样的问题。

    哦,天哪,我在用鱼。我必须看看这是否是鱼类特有的问题 /bin/sh )

    1 回复  |  直到 7 年前
        1
  •  0
  •   Samuel Vijaykumar    7 年前

    如果您希望并维护不同版本的python, asdf

    git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.6.2
    

    既然你似乎在用鱼,你可以做以下事情

    echo 'source ~/.asdf/asdf.fish' >> ~/.config/fish/config.fish
    mkdir -p ~/.config/fish/completions; and cp ~/.asdf/completions/asdf.fish ~/.config/fish/completions
    

    coreutils automake autoconf openssl libyaml readline libxslt libtool unixodbc ,因为插件可能需要它们。

    现在,您可以安装python插件了。首先需要拉它。

    asdf plugin-add python
    

    一旦你安装了插件,是时候安装你需要的版本了。

    asdf install python 3.5.6
    asdf install python 3.6.7
    

    成功安装后,您可以使用

    asdf global python <version-of-your-choice: eg. 3.5.6>
    

    如。

    我希望这有帮助。

        2
  •  0
  •   Jon    6 年前

    time.h . 问题是,我有一个流浪者,缺乏必要的出口 /usr/local/include . 如果您正在(mis)使用brew,则可能会链接到大量冗余、过期和冲突的头/lib /usr/local/* . 我建议获得详细的输出,找到产生错误的确切构建命令,查看每个 -I 时间 . 我打赌其中一个是你想扔掉的遗物。