How to embed properly using Python for .NET

*爱你&永不变心* 提交于 2019-12-08 05:04:41

问题


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:


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.



来源:https://stackoverflow.com/questions/25101718/how-to-embed-properly-using-python-for-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!