python-c-extension

Python extension module with variable number of arguments

≡放荡痞女 提交于 2019-11-27 03:16:56
问题 I am trying to figure out how in C extension modules to have a variable (and maybe) quite large number of arguments to a function. Reading about PyArg_ParseTuple it seems you have to know how many to accept, some mandatory and some optional but all with their own variable. I was hoping PyArg_UnpackTuple would be able to handle this but it seems to just give me bus errors when I try and use it in what appears to be the wrong way. As an example take the following python code that one might want

ImportError: dynamic module does not define init function (initfizzbuzz)

走远了吗. 提交于 2019-11-27 00:42:13
问题 I tried to compile fizzbuzz.c to import from python. For building fizzbuzz.c ,I used python setup.py build_ext -i . After building it, I tried to import fizzbuzz.c but the error below occurred. How can I solve this problem ? Error >>> import fizzbuzz Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: dynamic module does not define init function (initfizzbuzz) fizzbuzz.c #include <stdio.h> void fizzbuzz(int n){ for (int i=1; i <= n; i++){ if (i % 3 == 0 && i %

PyEval_InitThreads in Python 3: How/when to call it? (the saga continues ad nauseam)

无人久伴 提交于 2019-11-26 20:04:25
Basically there seems to be massive confusion/ambiguity over when exactly PyEval_InitThreads() is supposed to be called, and what accompanying API calls are needed. The official Python documentation is unfortunately very ambiguous. There are already many questions on stackoverflow regarding this topic, and indeed, I've personally already asked a question almost identical to this one, so I won't be particularly surprised if this is closed as a duplicate; but consider that there seems to be no definitive answer to this question. (Sadly, I don't have Guido Van Rossum on speed-dial.) Firstly, let

Building lxml for Python 2.7 on Windows

空扰寡人 提交于 2019-11-26 18:27:23
I am trying to build lxml for Python 2.7 on Windows 64 bit machine. I couldn't find lxml egg for Python 2.7 version. So I am compiling it from sources. I am following instructions on this site http://lxml.de/build.html under static linking section. I am getting error C:\Documents and Settings\Administrator\Desktop\lxmlpackage\lxml-2.2.6\lxml-2.2. 6>python setup.py bdist_wininst --static Building lxml version 2.2.6. NOTE: Trying to build without Cython, pre-generated 'src/lxml/lxml.etree.c' need s to be available. ERROR: 'xslt-config' is not recognized as an internal or external command,

Building lxml for Python 2.7 on Windows

对着背影说爱祢 提交于 2019-11-26 12:15:51
问题 I am trying to build lxml for Python 2.7 on Windows 64 bit machine. I couldn\'t find lxml egg for Python 2.7 version. So I am compiling it from sources. I am following instructions on this site http://lxml.de/build.html under static linking section. I am getting error C:\\Documents and Settings\\Administrator\\Desktop\\lxmlpackage\\lxml-2.2.6\\lxml-2.2. 6>python setup.py bdist_wininst --static Building lxml version 2.2.6. NOTE: Trying to build without Cython, pre-generated \'src/lxml/lxml

PyEval_InitThreads in Python 3: How/when to call it? (the saga continues ad nauseam)

Deadly 提交于 2019-11-26 06:32:46
问题 Basically there seems to be massive confusion/ambiguity over when exactly PyEval_InitThreads() is supposed to be called, and what accompanying API calls are needed. The official Python documentation is unfortunately very ambiguous. There are already many questions on stackoverflow regarding this topic, and indeed, I\'ve personally already asked a question almost identical to this one, so I won\'t be particularly surprised if this is closed as a duplicate; but consider that there seems to be

fatal error: Python.h: No such file or directory

自古美人都是妖i 提交于 2019-11-25 22:27:47
问题 I am trying to build a shared library using a C extension file but first I have to generate the output file using the command below: gcc -Wall utilsmodule.c -o Utilc After executing the command, I get this error message: utilsmodule.c:1:20: fatal error: Python.h: No such file or directory compilation terminated. in fact I have tried all the suggested solutions over the internet but the problem still exists ... also I have no problem with Python.h . I managed to locate the file on my machine .