简体   繁体   English

将python模块导入.net - “没有模块名为signal”

[英]Importing a python module to .net - “No module named signal”

I'm trying to import a Python module in a C# code like this: 我正在尝试在C#代码中导入Python模块,如下所示:

        var setup = Python.CreateRuntimeSetup(null);
        var runtime = new ScriptRuntime(setup);
        var engine = Python.GetEngine(runtime);
        var module = engine.ImportModule("mymodule");

but I get an error saying "No module named signal", does this mean that IronPython just can't load the signal module, is it OS specific? 但我得到一个错误,说“没有模块命名信号”,这是否意味着IronPython只是无法加载信号模块,是否是操作系统特定的?

Can anyone think of a workaround? 谁能想到一个解决方法?

The 'signal' module is used to handle all that has to do with ... you guessed it: signals. “信号”模块用于处理所有与...有关的事情......你猜对了:信号。 There are special "messages" that the OS send to a process to tell it something: eg. 操作系统发送给流程的特殊“消息”告诉它一些事情:例如。 Break, Kill, Terminate, etc... The exact set of message are generally OS specific, but as the signals python manual page states, python emulates BSD style interface, except for SIGCHLD. Break,Kill,Terminate等...确切的消息集通常是OS特定的,但是作为信号 python手册页状态,python模拟BSD样式接口,SIGCHLD除外。

Now, in CPython, the 'signal' module is a built-in as far as I can remember, it could possibly be that IronPython has not implemented it, in fact, a quick google and look on IronPython's site leads to this: IronPython and CPython differences (read it, in particular, the extension modules part!) 现在,在CPython中,'信号'模块是内置的,据我记忆所料,可能是IronPython还没有实现它,事实上,快速google并且看看IronPython的网站导致这个: IronPython和CPython差异 (阅读它,特别是扩展模块部分!)

Possible workaround: edit your module not to use signals when in IronPython 可能的解决方法:在IronPython中编辑模块时不要使用信号

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM