python - Mojave 上的 pyenv 在安装 3.5.6、3.6.7 时抛出未声明的标识符“CLOCK_REALTIME”和其他错误
问题描述
我正在尝试在 macOS Mojave 上安装各种版本的 python3 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
:
- 重新安装所有
pyenv
,python
,python3
,xz
,readline
,openssl
(根据这个答案) - 我已经尝试安装和重新安装 macOS 开发者工具
- 我试过
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
(根据 pyenv 文档) - 我在一个新的 Mojave running 版本上尝试了这个
10.14.1 (18B75)
,我遇到了同样的问题。
哦,该死的,我正在使用 Fish。我将不得不看看这是否是鱼特定的问题(更新:不,它不是鱼,它发生在标准中/bin/sh
)
解决方案
我不知道这是否是问题所在,但是当我尝试安装多个 pip 包时遇到了类似的错误,这些 pip 包的构建步骤依赖于time.h
. 问题是我有一个流浪者,里面缺乏必要的出口/usr/local/include
。如果您(错误)使用 brew,您可能会在/usr/local/*
. 我建议获取详细的输出,找到产生错误的确切构建命令,查看每个-I
标志,然后递归搜索time.h
. 我敢打赌,其中一个是你想要摆脱的遗物。
推荐阅读
- python - 有没有办法描述/类型提示函数参数的内容?
- python - 代码要求多个用户输入,但需要对每个单独的输入做不同的事情
- google-cloud-platform - 云大表行过滤的性能
- http - HTTP POST 请求响应 400 错误请求
- javascript - 仅从数组中的每个对象中提取某些属性,并添加到新数组中
- bash - 在bash linux中要求用户输入日期“而”他没有输入日期
- java - 预期为 BEGIN_ARRAY,但在第 1 行第 2 列路径处为 BEGIN_OBJECT,尽管 JSON 正确
- javascript - 需要帮忙。我删除了数据库中的 MongoDB 文档,但我的应用程序继续使用 AJAX 显示它们
- javascript - es6过滤并找到相同的对象
- android - 无法将我自己的 SMS 应用程序设置为默认值。任何建议如何解决它?