Skip to content

Cythonized python.net code cannot find system assemblies #941

Open
@crayxt

Description

@crayxt

Dup of my SO question https://stackoverflow.com/questions/57493309/cythonized-python-net-code-cannot-find-system-assemblies

When I compile the python code which uses python.net to access .Net assemblies, it can't find those assemblies. Without compilation it works ok.

For demo code, I used https://github.com/pythonnet/pythonnet/blob/master/demo/helloform.py

My setup.py file

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

ext_modules = [
    Extension(
        'helloform',
        sources = ['helloform.py'],
        language = 'c++'
      )
]

setup(
  name = 'helloform',
  ext_modules = cythonize(ext_modules),
)

Then I build it with python setup.py build_ext --inplace.

I wanted to load compiled module from Python prompt with import helloform but it failed with

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "helloform.py", line 8, in init helloform
ModuleNotFoundError: No module named 'System'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions