Ich habe dieses Tutorial verfolgt und es funktioniert in meiner .NET-App einwandfrei: https://medium.com/@hanxuyang0826/trigg ... b17d593dc6 < BR /> Wenn ich jedoch den Tutorial -Code in myapppython.py < /code> < /p>
ersetzeclass Calculator:
def AddInPython(self, a, b):
return a + b
< /code>
mit einem Python -Code von OpenAI: < /p>
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "What's in this image?"},
{
"type": "image_url",
"image_url": {
"url": "https://upload.wikimedia.org/wikipedia/ ... rdwalk.jpg",
},
},
],
}
],
max_tokens=300,
)
print(response.choices[0])
< /code>
Ich kann es nicht zum Laufen bringen. < /p>
using IronPython.Hosting;
using Microsoft.Scripting.Hosting;
using System.Diagnostics;
namespace MyApp.Areas.FunctionalLogic
{
public class IronPythonExample
{
public void ExecutePythonCode()
{
Debug.WriteLine("*****ExecutePythonCode*****");
// Create the IronPython scripting engine
ScriptEngine engine = Python.CreateEngine();
// Add the directory containing the Python file to the search paths
ICollection searchPaths = engine.GetSearchPaths();
searchPaths.Add("../MyAppPython");
engine.SetSearchPaths(searchPaths);
Debug.WriteLine("*****searchPath Set:" + searchPaths.ToString());
// Import the Python file
dynamic visionModule = engine.ImportModule("MyAppPython");
Debug.WriteLine("*****Python file imported*****");
// Create an instance of the Vision class
dynamic vision = visionModule();
Debug.WriteLine("*****Instance Created*****");
// Call the MyAppPython method
vision();
}
}
}
< /code>
Es scheint so weit wie hier in Ordnung zu sein, und löst dann eine Ausnahme aus: < /p>
Debug.WriteLine("*****searchPath Set:" + searchPaths.ToString());
< /code>
.
Exception thrown: 'IronPython.Runtime.Exceptions.ImportException' in Microsoft.Dynamic.dll
< /code>
Ich habe mich im Kreis mit diesen unterschiedlichen Variationen im Kreis befasst. Hat jemand irgendwelche Vorschläge?
Verwenden Sie Ironpython mit Python -Skript und .NET -Controller ⇐ Python
-
- Similar Topics
- Replies
- Views
- Last post
-
-
Wie rufe ich einen Controller von einem anderen Controller in Codesigniter auf?
by Anonymous » » in Php - 0 Replies
- 17 Views
-
Last post by Anonymous
-