我如何仅调用C#的Python脚本的一个函数,而不必连续打开整个文件和功能?

发布于 2025-02-01 07:48:08 字数 627 浏览 3 评论 0原文

我有一个.py脚本加载一些非常重的文件,我想从C#程序打开Python程序,并调用不同的函数,而不必连续打开模型。

  1. 我试图使用Ironpython函数来称呼它,但我会收到以下错误。 在此处输入图像描述

如果我尝试通过下一个代码添加: var SearchPaths = Engine.getSearchPaths(); 看来我是下一个错误_: 在此处输入图像描述

  1. 如果我尝试使用新过程来完成,我只能调用整个过程例行程序,在每次迭代中,我需要很长时间才能打开模型并执行该模型,仅当我只想在该过程启动后才调用函数。我该怎么做?我附加了以下我启动该过程的代码。 在此处输入图像描述

I have a .py script that loads some very heavy files and I would like to open the python program from a C# program and call the different functions without having to continuously open the model.

  1. I tried to call it with the IronPython function but I get the following error.
    enter image description here

If i try to add by the next code:
var searchPaths = engine.GetSearchPaths();
it appears me the next error_:
enter image description here

  1. If I try to do it with a new process I can only call the whole routine, and in each iteration it takes me a long time to open the model and execute it when I only want to call a function once the process has started. How can I do this? I attach the following code of how I start the process.
    enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文