lucacatr
lucacatr

Reputation: 101

cython convert python to c limit

I'm trying to convert a simple, and stupid, script from Python to C:

#script.pyx
import os
import sys
import numpy as np
from datetime import datetime

x = 5

So, following the tutorial I created setup.py file:

from distutils.core import setup
from Cython.Build import cythonize

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

When I try to run:

python setup.py build_ext --inplace

I have a correct c file like output but I have also this error:

tree = Parsing.p_module(s, pxd, full_module_name)
error: [WinError 2] Cannot find the specified file

From this result I got a doubt: with cython can I convert any Python script? Even the most complex? What are the limits? If I have a file that imports library and / or other classes? Thank you

Upvotes: 0

Views: 204

Answers (1)

user13676212
user13676212

Reputation:

Sometimes we need to fully specify where the script is, instead of just typing the name of the file, you must enter the full path, or you gotta cd to the right directory,

"/home/userrr/Desktop/folder45/script.pyx"

Instead of "script.pyx"

Of it still does not work, uninstall python, re install python and the reinstall Cython, another issue could be the pyx source code, pyx source code should be different from Normal python language, check the cdef function, cdef Cythonize Language also

Upvotes: 1

Related Questions