如何使用Python为.NET适当嵌入如何使用、适当、Python、NET

2023-09-04 03:37:52 作者:つ没有你我可以过得很好

当我尝试使用

PythonEngine.ImportModule(mymodulename)

一些相关性的可选模块都试图加载(不需要模块一起使用时不嵌入)。这导致返回NULL此方法,因为一些可选的依赖是不是必需的,因此不具备的。什么是正确的方法,在加载用户编写的模块,这PythonNET API,它取决于多种其他模块使用?

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?

我想从两个版本importhook.cs:

I tried importhook.cs from both versions:

https://github.com/pythonnet/pythonnet

https://github.com/renshawbay/pythonnet

推荐答案

看起来像我的问题,只是进口不带扩展名(的.py)模块。非常愚蠢的错误,但希望这有助于其他人谁与pythonnet开始。

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