[Python] Using Python.NET in a C# Azure function

Discussão em 'Python' iniciado por Stack, Maio 30, 2025.

  1. Stack

    Stack Membro Participativo

    We have developed all our functions using C#, and would like to continue doing so. But we have a parsing library written in Python that we'd like to use. We've therefor looked at Python.NET (pythonnet) to execute the Python code within our C# process.

    Everything works if I run it locally using a vanilla C# Console app. But when I move the same code to a Azure function project it fails (even locally).

    Runtime.PythonDLL = @"python310.dll";
    PythonEngine.Initialize();

    // This line fails with "No module named 'wmbus2json'"
    var parser = Py.Import(@"wmbus2json");


    It seams the runtime cannot find the Python files although they are in the bin directory. We are running our Azure Function using .net 6 Isolated

    Thanks for any help

    Continue reading...

Compartilhe esta Página