铁python抛出 - NO module named _jpype;
而在VS代码中运行相同的.py脚本时效果很好
以下python脚本在VSCode
中运行时效果很好import collections
import jaydebeapi
conn = jaydebeapi.connect("XXXXX","XXXX ","tl-jdbc-0.13.4-uber.jar")
curs = conn.cursor()
curs.execute("SELECT (RAW2STR(MESSAGE)) FROM XX.raw WHERE EXTERNAL_MESSAGE_ID ='XX")
print "OUTPUT >>>"
results = curs.fetchall()
print "Results"
print results
f = open('test.txt', 'w')
s = str(results)
f.write(s)
f.close()
print "<<<<< END"
curs.close()
conn.close()
但是当使用iron python调用它时会抛出错误 - 没有名为_jpype的模块
var py = Python.CreateEngine();
try
{
ICollection<string> paths = py.GetSearchPaths();
string dir = @"C:\Anaconda2\Lib\";
//paths.Add(dir);
string dir2 = @"C:\Anaconda2\Lib\site-packages";
paths.Add(dir2);
py.SetSearchPaths(paths);
py.ImportModule("_jpype");
py.ImportModule("jaydebeapi");
py.ExecuteFile(@"C:\Users\xxxx\repos\Python\XXX\XXXFileFetcher.py");
}
catch (Exception ex)
{
Console.WriteLine(
"Oops! We couldn't execute the script because of an exception: " + ex.Message);
}