我使用ZeroMQ在C管理的应用程序和python脚本之间进行进程间通信。当从C#调用脚本时,使用IronPython我得到以下错误:
An unhandled exception of type
IronPython.Runtime.Exceptions.ImportException
occurred in
Microsoft.Dynamic.dllAdditional information: cannot import constants from
zmq.backend.cython
Python代码(测试.py文件):
import sys, zmq, time
def execute(input):
context = zmq.Context()
publisher = context.socket(zmq.PUB)
publisher.bind("tcp://*:18800")
time.sleep(1)
publisher.send(input) #just echo input parameter
这就是我在C应用程序中执行.py代码的方式:
^{pr2}$注意,为了简洁起见,省略了一些代码,实际上与此场景无关。当通过命令行手动调用.py脚本时,一切正常,我可以传递数据,我的C应用程序正在接收消息。在
有人知道这是什么错误,如何解决?在
EDIT :
当我绝望并几乎放弃时,我试图编写快速命名管道支持,猜猜是什么-类似的错误:
An unhandled exception of type
IronPython.Runtime.Exceptions.ImportException
occurred in
Microsoft.Dynamic.dllAdditional information: No module named win32file
这次,我的测试.py看起来像这样:
import win32file
def execute(input):
handle = win32file.CreateFile(r"\\.\pipe\test_pipe",
win32file.GENERIC_WRITE,
0, None,
win32file.OPEN_EXISTING,
0, None)
if handle:
win32file.WriteFile(self.handle, input, None)
win32file.FlushFileBuffers(self.handle)
win32file.SetFilePointer(self.handle, 0, win32file.FILE_BEGIN)
对于这种互操作性,我不太确定是否有更多的选择,但我开始认为IronPython可以覆盖基本的使用场景(当从C调用纯python代码时),更不用说我以后肯定需要的matplotlib
、numpy
或astropy
。在
提前谢谢!在
此致,
Civa公司
目前没有回答
相关问题 更多 >
编程相关推荐