Search code examples
pythoncx-freeze

ModuleNotFoundError error from .pyd file


I had to to transform a module from .py to .pyd. I did it with Cython. I tested after the project, and everything worked fine. When I created a build with cx_Freeze, that .pyd module created problems. I can't understand why after building I get this ModuleNotFoundError.

 File "tooth_comp.pyx", line 13, in int
src.graphics_dental_components.tooth_comp
ModuleNotFoundError: No module named 'graphics_utils.effects' 

My setup script:

import sys
from cx_Freeze import setup, Executable

packages = []
excludes = []
include_files = ["assets", "views"]

build_exe_options = {"packages": packages, "excludes": excludes, "include_files": include_files}

base = None
if sys.platform == "win32":
    base = "Win32GUI"

setup(  name = "MyApp",
        version = "0.1",
        description = "My GUI application!",
        options = {"build_exe": build_exe_options},
        executables = [Executable("app.py", base=base)])

Solution

  • The reason for the error message is because the application cannot find the extension.

    Try adding graphics_utils.effects to the packages list then try recompiling.

    If that does not work you could also try coping the module in the build folder manually.