Cythonizing fails because of unknown type name uint64_t

2024/10/6 1:36:52

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")

Here is the setup.py script:

from distutils.core import setupfrom Cython.Build import cythonizesetup(ext_modules = cythonize('helloworld.pyx'))

But I get this after running 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

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

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

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

gcc --version

shows:

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
Answer

I faced a similar situation after migrating to a new Mac. Just reinstalling brew did not solve the issues. I had to remove /usr/local/include to fix the issue.

(Comment from Cython Issue on Github)

https://en.xdnf.cn/q/70419.html

Related Q&A

How to save changes in read-only Jupyter Notebook

I have opened a python Jupyter notebook but did not notice that it was in read-only, Not Trusted mode. How to save my changes now?Things that I have tried and did not help:File -> Make a Copy File …

How can I invoke an SQLAlchemy query with limit of 1?

I have code like this:thing = thing.query.filter_by(id=thing_id).limit(1).all()[0]all()[0] feels a bit messy and redundant in the limit(1) case. Is there a more terse (and/or otherwise optimal) way to …

How to correctly create Python feature branch releases in development? (pip and PEP-440)

I develop a Python library using Gitflow development principle and have a CI stage for unit testing and package upload to a (private) PyPI. I want to consume the uploaded package for testing purposes b…

How do I replace NA with NaN in a Pandas DataFrame?

Some columns in my DataFrame have instances of <NA> which are of type pandas._libs.missing.NAType. Id like to replace them with NaN using np.nan. I have seen questions where the instances of <…

concatenation of two or more base64 strings in python

Im tring to concatenate two strings encoded to base64 but it doesnt really work, just prints the first string in concatanation:q = base64.b64encode("StringA") print q # prints an encoded stri…

How to find shared library used by a python module?

I am debugging a python program based on pygtk and I want to make sure that the program is using the right shared library.pygtk is a GTK+ wrapper for python. I have already compiled GTK+ using jhbuild …

Python groupby doesnt work as expected [duplicate]

This question already has answers here:itertools.groupby() not grouping correctly(3 answers)Closed 5 years ago.I am trying to read an excel spreadsheet that contains some columns in following format:co…

Dask: create strictly increasing index

As is well documented, Dask creates a strictly increasing index on a per partition basis when reset_index is called, resulting in duplicate indices over the whole set. What is the best way (e.g. comput…

Installing hunspell package

Im looking forward to install the hunspell package using pip, but it throws the following error:Collecting hunspellUsing cached hunspell-0.4.1.tar.gz Building wheels for collected packages: hunspellRun…

Flask-Restful taking over exception handling from Flask during non debug mode

Ive used Flasks exception handling during development (@app.errorhander(MyException)) which worked fine even for exceptions coming from Flask-Restful endpoints.However, I noticed that when switching to…