问题
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