导致Cythonization失败

导致Cythonization失败

本文介绍了由于未知的类型名称'uint64_t',导致Cythonization失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是新手问题。我无法对简单的helloworld.pyx教程脚本进行cythonize,而在Linux上可以使用完全相同的代码:

This may be a newbie problem. I can't cythonize a simple helloworld.pyx tutorial script while the exact same code works on linux:

print("hello world")

这是setup.py脚本:

Here is the setup.py script:

from distutils.core import setup

from Cython.Build import cythonize

setup(ext_modules = cythonize('helloworld.pyx'))

但是我在运行 python setup.py build_ext后得到了这个--inplace

running build_ext
building 'helloworld' extension
creating build
creating build/temp.macosx-10.7-x86_64-3.6
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/haotian/anaconda3/include -arch x86_64 -I/Users/haotian/anaconda3/include -arch x86_64 -I/Users/haotian/anaconda3/include/python3.6m -c helloworld.c -o build/temp.macosx-10.7-x86_64-3.6/helloworld.o
In file included from helloworld.c:16:
In file included from /Users/haotian/anaconda3/include/python3.6m/Python.h:34:
In file included from /usr/include/stdlib.h:65:
In file included from /usr/include/sys/wait.h:110:
/usr/include/sys/resource.h:196:2: error: unknown type name 'uint8_t'
        uint8_t  ri_uuid[16];
        ^
/usr/include/sys/resource.h:197:2: error: unknown type name 'uint64_t'
        uint64_t ri_user_time;
        ^
/usr/include/sys/resource.h:198:2: error: unknown type name 'uint64_t'
        uint64_t ri_system_time;
        ^
/usr/include/sys/resource.h:199:2: error: unknown type name 'uint64_t'
        uint64_t ri_pkg_idle_wkups;
        ^
/usr/include/sys/resource.h:200:2: error: unknown type name 'uint64_t'
        uint64_t ri_interrupt_wkups;
        ^
/usr/include/sys/resource.h:201:2: error: unknown type name 'uint64_t'
        uint64_t ri_pageins;
        ^
/usr/include/sys/resource.h:202:2: error: unknown type name 'uint64_t'
        uint64_t ri_wired_size;
        ^
/usr/include/sys/resource.h:203:2: error: unknown type name 'uint64_t'
        uint64_t ri_resident_size;
        ^
/usr/include/sys/resource.h:204:2: error: unknown type name 'uint64_t'
        uint64_t ri_phys_footprint;
        ^
/usr/include/sys/resource.h:205:2: error: unknown type name 'uint64_t'
        uint64_t ri_proc_start_abstime;
        ^
/usr/include/sys/resource.h:206:2: error: unknown type name 'uint64_t'
        uint64_t ri_proc_exit_abstime;
        ^
/usr/include/sys/resource.h:210:2: error: unknown type name 'uint8_t'
        uint8_t  ri_uuid[16];
        ^
/usr/include/sys/resource.h:211:2: error: unknown type name 'uint64_t'
        uint64_t ri_user_time;
        ^
/usr/include/sys/resource.h:212:2: error: unknown type name 'uint64_t'
        uint64_t ri_system_time;
        ^
/usr/include/sys/resource.h:213:2: error: unknown type name 'uint64_t'
        uint64_t ri_pkg_idle_wkups;
        ^
/usr/include/sys/resource.h:214:2: error: unknown type name 'uint64_t'
        uint64_t ri_interrupt_wkups;
        ^
/usr/include/sys/resource.h:215:2: error: unknown type name 'uint64_t'
        uint64_t ri_pageins;
        ^
/usr/include/sys/resource.h:216:2: error: unknown type name 'uint64_t'
        uint64_t ri_wired_size;
        ^
/usr/include/sys/resource.h:217:2: error: unknown type name 'uint64_t'
        uint64_t ri_resident_size;
        ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
error: command 'gcc' failed with exit status 1

我在MacOS 10.13上.1,python 3.6.3,Cython 0.27.3和clang-900.0.38。

I'm on MacOS 10.13.1, python 3.6.3, Cython 0.27.3 and clang-900.0.38.

显然,包含stdint.h存在问题,我该怎么办

Apparently there is a problem with including stdint.h, how should I go about doing it in Cython?

编辑
我的gcc在/ usr / bin / gcc

EDIT:My gcc is in /usr/bin/gcc

gcc --version

显示:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.0.0 (clang-900.0.38)
Target: x86_64-apple-darwin17.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin


推荐答案

我找到了解决我问题的方法。

I have found a solution to my problem.

在安装了High Sierra之后,似乎有些/ usr / local / include中的头文件混乱会导致咖啡机安装出现故障。卸载并重新安装brew解决了该问题。

It seems like after installing High Sierra some header files in the /usr/local/include are messed up, and causing the brew installation to malfunction. Uninstall and reinstalling brew solved the problem.

rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install )"

这篇关于由于未知的类型名称'uint64_t',导致Cythonization失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 20:40