使用C#运行python脚本

时间:2019-03-10 08:12:25

标签: c# python integration ironpython

我尝试在c#上运行python脚本。 脚本开始

import time
import serial
import sys
sys.path.append("c:\python27\lib")

我尝试过:

        var engine = Python.CreateEngine();
        var paths = engine.GetSearchPaths();
        paths.Add(@"c:\Program Files (x86)\IronPython 2.7\Platforms\Net40");
        paths.Add(@"C:\Python27\Lib");
        engine.SetSearchPaths(paths);
        var ipy = Python.CreateRuntime();
        dynamic py = ipy.UseFile(@"C:\boris\serialCapture.py");
        py.start_element();

我遇到以下错误

enter image description here

0 个答案:

没有答案