How to embed properly using Python for .NET

2019-06-04 04:19发布

When I try to use

PythonEngine.ImportModule(mymodulename)

some of the optional modules in dependencies are attempted to be loaded (not required for module use without embedding). This results in return null from this method because some of these optional dependencies are not required and hence not available. What is the proper method to use in this PythonNET API for loading user-written module which depends on multiple other modules?

1条回答
爷、活的狠高调
2楼-- · 2019-06-04 04:34

Looks like my issue was just importing the module without extension (.py). Very stupid mistake, but hope this helps others who start with pythonnet.

For one-file modules with .py(c) extension, full file name including extension is required.

For packages (directory with __init__.py and other files, subdirectories) only package name is required.

查看更多
登录 后发表回答