C module import in Python (Using Cython)

247 Views Asked by At

How do I import a C module in python that was generated with Cython?

I have tried the normal way:

from app.CythonOperations import executor_unpack

Could this be that python3 may not be able to recognize cpdef or cdef functions in C? When running it locally, this gives me no issues. When deploying to the Okteto Cloud, the logs say:

ImportError: cannot import name 'executor_unpack' from 'app.CythonOperations' (unknown location)

This is my executor_unpack.pyx file:

cpdef executor_read(list results):
    cdef list response_packet = [[], []]
    cdef list data = []
    cdef list supplied = []
    cdef dict d = {}
    cdef dict s = {}

    for result in results:
        data = result[0]
        supplied = result[1]
        for d, s in zip(data, supplied):
            response_packet[0].append(d)
            response_packet[1].append(s)

    return response_packet

I also have the executor_unpack.c file present in CythonOperations directory. The executor_unpack.pyx file is not in the same directory. I am currently deploying this software and would appreciate anyone's thoughts on how to fix this issue :) Thanks.

0

There are 0 best solutions below