How to integrate Python Code with C#.Net Core language? [closed]
Asked Answered
T

2

15

Am trying to integrate python code in my .net core application for data analysis and some machine learning classification. How can I do this the best way?

Note: I don't want to execute scripts with IronPython. I already tried that before.

Trampoline answered 23/8, 2018 at 20:51 Comment(5)
"How do I integrate X with Y" is not really a good fit for StackOverflow.Gaylene
I know my question is weird, but thanks for commenting.Trampoline
How do you want to integrate it without an interpreter like IronPython?Branchia
IronPython is the preferred way to provide Python scripting capability in .NET. If you don't want to do that, please explain why.Kress
@Kress IronPython is quite weak. It doesn't allow you to import pandas or numpyAerosphere
I
15

If IronPython isn't a good match, Python for .Net might work for you. It integrates the CPython runtime (and thus any Python libraries, including native libraries that run under CPython) into your .Net process. .Net objects can call Python objects, and vice versa, without too much trouble. I've used it to integrate Python and C#-coded tools together behind a single WPF UI.

Illegible answered 23/8, 2018 at 21:1 Comment(0)
F
2

I once did something similar to this (but in vb.net). I used system calls to call my python scripts.

Process.Start("py_script.py");

IF you need to get data back/returned from your python scripts to your .NET program.... in my actual Python script, I wrote data (that needed to be returned back to my .net application) to text files. Then in my .net code I read the files in to retrieve the data. There may be other ways but this solution worked for me. Don't forget to code the removal/clean up of the text files after the Python script has executed.

I would have used Ironpython as mentioned in the other answer... however the python modules that I needed were not available via Ironpython. Maybe that has changed now... not sure. But that was a BIG ISSUE for me.

Final answered 23/8, 2018 at 21:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.