Question Can I use Python libraries in a .NET AI app? Is this approach feasible and performant?

riddhi

New member
Joined
Apr 25, 2025
Messages
1
Programming Experience
Beginner
Hi all,
I’m planning to build an AI-driven application where I’d prefer to write the main logic and structure in .NET (C#) for better control and integration with existing systems.
However, some of the functionalities I need are available in Python libraries, such as:
  • azure-cognitiveservices-vision-computervision (for image analysis)
  • openai (for LLMs and generative AI)
  • pymupdf and reportlab (for PDF processing and generation)
  • python-multipart, Pillow, and weasyprint (for file uploads, image processing, and document rendering)

My questions:​

  • Is it feasible to use these Python libraries within a .NET application using interop tools like pythonnet or IronPython?
  • Can this setup work well for production-level AI applications?
  • Are there any performance drawbacks, integration challenges, or better alternatives for this hybrid approach?
  • Would you recommend this model or suggest switching entirely to a Python or .NET stack depending on the use case?
I’d really appreciate any insights or real-world experiences from those who’ve tried combining Python and .NET in similar projects.
 
Is it feasible to use these Python libraries within a .NET application using interop tools like pythonnet or IronPython?

Yes, with IronPython if the libraries you are using are written in pure Python. If the libraries are dependent on C/C++ libraries, then no.

Yes, if those Python libraries expose any C style APIs, then you can use C#'s P/Invoke to call the C APIs.

My personal recommendation would be to keep the Python stuff in Python, and compile some adapter/wrapper module as standalone executables. Then use ShellExecute() to run those adapters/wrappers. <sarcasm>If this approach is good enough for git which shells out to run other executables, then it should be good enough for production work.</sarcasm>
 
Back
Top Bottom