我正在使用VisualStudio2017并安装NuGet包:IronPython。你知道吗
我需要能够让python脚本在C应用程序中工作,而无需最终用户安装python。我可以通过IronPython让基本的应用程序毫无问题地运行,然后我使用脚本工作所需的库进行了测试,它不再只使用IronPython,然后它需要指向我的python Lib文件夹才能获得它所需的库。有没有办法解决这个问题,或者最终用户将别无选择,只能在他们的计算机上安装python和库来让我的应用程序工作?你知道吗
你知道吗 参考代码:
使用IronPython.托管
namespace testApp {
class Program {
static void Main(string[] args) {
var py = Python.CreateEngine();
try {
py.ExecuteFile(@"python\test.py");
}
catch (Exception ex) {
Console.WriteLine(ex.Message + " - Error from visual studio");
}
Console.Read();
}
}
}
Python:
import sys
sys.path.append(r"C:\Users\Owner\AppData\Local\Programs\Python\Python36-32\Lib") # points to python interpreter
import os
from reportlab.pdfgen import canvas
c = canvas.Canvas("Test.pdf")
c.drawString(100, 100, "This is some test text!")
c.showPage()
c.save()
目前没有回答
相关问题 更多 >
编程相关推荐