【问题标题】:pyenv on Mojave throwing undeclared identifier 'CLOCK_REALTIME' and other errors when installing 3.5.6, 3.6.7Mojave 上的 pyenv 在安装 3.5.6、3.6.7 时抛出未声明的标识符“CLOCK_REALTIME”和其他错误
【发布时间】:2018-12-04 20:07:12
【问题描述】:

我正在尝试在 macOS Mojave 10.14.2 Beta (18C52a) 上安装各种版本的 python3。

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. 重新安装所有pyenvpythonpython3xzreadlineopenssl(每个this answer
  2. 我已尝试安装和重新安装 macOS 开发者工具
  3. 我试过 sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /(根据 pyenv 文档)
  4. 我在运行 10.14.1 (18B75) 的新版 Mojave 上进行了尝试,但遇到了同样的问题。

哦,该死的,我正在使用 Fish。我得看看这是不是鱼特有的问题?????? (更新:不,这不是 Fish,它发生在标准 /bin/sh 中)

【问题讨论】:

  • 您是否尝试通过 Github 从源代码安装 pyenv 以查看是否可行? github.com/pyenv/pyenv#basic-github-checkout 。您还安装了最新版本的 gcc 和 xcode 吗?
  • 没有尝试从源代码构建,我会试一试。还更好地仔细检查哪个 Xcode 版本处于活动状态...好电话。
  • 别担心,让我知道,想看看结果如何 :)
  • 不是您问题的具体解决方案;我在尝试安装 python 2 时遇到了同样的问题,我通过安装 miniconda2 版本来解决它。
  • 能否请您发布完整的日志文件?

标签: python python-3.x macos macos-mojave pyenv


【解决方案1】:

如果您愿意并维护不同版本的 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

此时您需要重新启动终端以使 asdf 生效。一个 Mac 操作系统,您可能需要自制安装 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>

例如。 asdf 全局 python 3.5.6

我希望这会有所帮助。

【讨论】:

  • 似乎有关于此问题的报告,herehere
【解决方案2】:

我不知道这是否是问题所在,但是当我尝试安装多个 pip 包时遇到了类似的错误,这些 pip 包的构建步骤依赖于time.h。问题是我有一个在/usr/local/include 中缺少必要导出的流浪者。如果您(错误)使用 brew,您可能在/usr/local/* 中链接了许多冗余、过时和冲突的标头/库。我建议获得详细的输出,找到产生错误的确切构建命令,查看每个-I 标志,然后递归搜索time.h。我敢打赌,其中一个是你想摆脱的遗物。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-01
    • 2013-03-12
    • 1970-01-01
    • 1970-01-01
    • 2013-01-22
    相关资源
    最近更新 更多