Import costum PYD module inside a Python code block

I tried to import a compiled Python-module inside a Dynamo code block, but i cant get it to work.

The file “example_module.pyd” was created the following way:
cythonize -i -3 example_module.py

example_module.py:

def greet(name):
    return f"Hello, {name} :D"

Python code block:

# Import builtin library
import sys

# Append path to list
sys.path.append("path-to-pyd-folder")

# Import pyd module
import example_module

module_path = example_module.__file__
return_value = example_module.greet("Dynamo")

OUT = [module_path, return_value]

But i only get a error message: ImportError : DLL load failed while importing example_module.

Does anybody have a idea how to fix this error? Unfortunately as a new user i cannot upload any data to let you test the file.

Kind regards
Phil

Hi,

try to use pyc format instead with py_compile module

an example

1 Like

Hi Cyril,

thank you for your fast reply! I know the pyc module import, but would like to make them available as pyd/dll. And since my approach works in a “normal” Python environment, I would also like to use it under Dynamo.

Kind regards
Phil