Skip to content Skip to sidebar Skip to footer

Cython Compile Error "is Not A Valid Module Name"

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 conso

Solution 1:

First, change your setup.py file to only use distutils

fromCython.Buildimport cythonize
from distutils.coreimport setup, Extensionsetup(
    name = "Consolidated Loop",
    ext_modules = cythonize("consolidated_loop_C.pyx")
)

This is to facilitate the debugging for potential repliers.

Then, from a few experiments and other SO posts Python building cython extension with setup creates subfolder when __init__.py exists and The command `python setup.py build_ext --inplace` always create a new directory

I suggest to either move your cython file in a subdirectory or remove the __init__.py file. The latter issue very probably causes Python or Cython to guess the name of the module of the current directory, hence the dash issue. Also, setup.py files cannot live in the directory of the module and that will cause trouble.

If you intend to distribute or package your code, the former option (moving cleanly the files in a subdirectory with its own __init__.py, etc) is preferable. Else, just remove __init__.py and be done. This will create, with build_ext --inplace, a locally available Python module consolidated_loop_C.so.

Post a Comment for "Cython Compile Error "is Not A Valid Module Name""