cython

What does CompileError/LinkerError: “command 'gcc' failed with exit status 1” mean, when running %%cython-magic cell in IPython

我只是一个虾纸丫 提交于 2020-01-05 15:17:26
问题 Sometimes, when I run a %%cython-cell in an IPython-notebook I get a long backtrace with ends with a quite short error message: CompileError: command 'gcc' failed with exit status 1 or LinkError: command 'gcc' failed with exit status 1 On Windows the corresponding messages are: CompileError: command 'C:.\Microsoft Visual Studio\..\cl.exe' failed with exit status X and LinkError: command 'C:..\Microsoft Visual Studio\..\link.exe' failed with exit status YYYY Is it possible to get more precise

What does CompileError/LinkerError: “command 'gcc' failed with exit status 1” mean, when running %%cython-magic cell in IPython

你说的曾经没有我的故事 提交于 2020-01-05 15:17:22
问题 Sometimes, when I run a %%cython-cell in an IPython-notebook I get a long backtrace with ends with a quite short error message: CompileError: command 'gcc' failed with exit status 1 or LinkError: command 'gcc' failed with exit status 1 On Windows the corresponding messages are: CompileError: command 'C:.\Microsoft Visual Studio\..\cl.exe' failed with exit status X and LinkError: command 'C:..\Microsoft Visual Studio\..\link.exe' failed with exit status YYYY Is it possible to get more precise

Cython compile error “is not a valid module name”

旧时模样 提交于 2020-01-05 06:42:29
问题 I trying to compile on windows a Cython file (.pyx), a file which I just saved from .py. Here is my project dir path. c:\..\Project\App\Analyzer\ _init_.py Few_other_files.py consolidated_loop_C.pyx cl_setup.py Here is my cl_setup.py from Cython.Build import cythonize try: from setuptools import setup from setuptools import Extension except ImportError: from distutils.core import setup from distutils.extension import Extension setup( name = "Consolidated Loop", ext_modules = cythonize(

Cython compile error “is not a valid module name”

你离开我真会死。 提交于 2020-01-05 06:42:13
问题 I trying to compile on windows a Cython file (.pyx), a file which I just saved from .py. Here is my project dir path. c:\..\Project\App\Analyzer\ _init_.py Few_other_files.py consolidated_loop_C.pyx cl_setup.py Here is my cl_setup.py from Cython.Build import cythonize try: from setuptools import setup from setuptools import Extension except ImportError: from distutils.core import setup from distutils.extension import Extension setup( name = "Consolidated Loop", ext_modules = cythonize(

Confusing reference ownership: how to properly deallocate (via Py_DECREF) objects of an object?

岁酱吖の 提交于 2020-01-05 06:30:11
问题 I was analysing the following code, which compiles and runs correctly, but generates a memory leak. The cfiboheap is a C implementation of a Fibonacci Heap and the following code is a Cython wrapper (a part of it) for cfiboheap . My doubts starts on the insert function. The object data has been created somewhere and passed to the function insert() . Since the function wants to add this object to the fiboheap it increases its reference count. But afterwards? To whom the ownership goes? In my

Confusing reference ownership: how to properly deallocate (via Py_DECREF) objects of an object?

旧街凉风 提交于 2020-01-05 06:30:11
问题 I was analysing the following code, which compiles and runs correctly, but generates a memory leak. The cfiboheap is a C implementation of a Fibonacci Heap and the following code is a Cython wrapper (a part of it) for cfiboheap . My doubts starts on the insert function. The object data has been created somewhere and passed to the function insert() . Since the function wants to add this object to the fiboheap it increases its reference count. But afterwards? To whom the ownership goes? In my

How to wrap a C function whose parameter is wchar_t pointer with cython

放肆的年华 提交于 2020-01-05 05:25:34
问题 I want to use cython to wrap a C library. One function in the library is like int hid_get_manufacturer_string(hid_device *device, wchar_t *string, size_t maxlen); There are two questions: What can I do with the wchar_t in cython; How to convert the string pointer in my .pyx file. 回答1: Declare wchar_t: cdef extern from "stddef.h": ctypedef void wchar_t Or import from libc module: from libc.stddef cimport wchar_t A function to convert wchar_t to python string by using WideCharToMultiByte (see

Strange Segmentation Fault in PyArray_SimpleNewFromData

不打扰是莪最后的温柔 提交于 2020-01-05 05:20:44
问题 My question is similar "in spirit" to Segmentation fault in PyArray_SimpleNewFromData I have a C code that looks like this: (original code actually tests if malloc() returned NULL) 1 #include <Python.h> 2 #include <numpy/arrayobject.h> // (Not sure if right import) 3 #include <stdlib.h> 4 #include <stdio.h> 5 6 double *calculate_dW(npy_intp *dim_w) { 7 int i; 8 double* data = (double*)malloc(sizeof(double) * dim_w[0]); 9 10 /* Inserts some dummy data */ 11 for (i = 0; i < dim_w[0]; i++) 12

distribution : how to build a compiled module for multiple python version and platform

我的梦境 提交于 2020-01-05 04:30:48
问题 I have build a python 3 module for my own process. I use cython to compile and wrap C++ sources. I have a linux (Debian Jessie) machine with python 3.4 and so cythonize make me a Processing.cpython-34m.so and copy it to /usr/local/lib/python3.4/dist-packages . But when I use it on another machine which has python3.5, I have to recompile everything. How can I build a linux or pip package from my machine for all python 3 version and multiple platforms (here, just Jessie and Stretch, which might

Why can't cython memory views be pickled?

妖精的绣舞 提交于 2020-01-04 13:46:34
问题 I have a cython module that uses memoryview arrays, that is... double[:,:] foo I want to run this module in parallel using multiprocessing. However I get the error: PicklingError: Can't pickle <type 'tile_class._memoryviewslice'>: attribute lookup tile_class._memoryviewslice failed Why can't I pickle a memory view and what can I do about it. 回答1: Maybe passing the actual array instead of the memory view can solve your problem. If you want to execute a function in parallel, all of it