PythonNet - Embedding Python in .NET

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ม.ค. 2025

ความคิดเห็น • 38

  • @senthilkumarpalanisamy365
    @senthilkumarpalanisamy365 3 ปีที่แล้ว +23

    Excellent video bro. Please post more. Also use pandas dataframe next time.

    • @Orell1986
      @Orell1986  3 ปีที่แล้ว +4

      If your comment gets enough likes, then yes, I'll make a Pandas video :)

  • @KiranSuman-od2vt
    @KiranSuman-od2vt ปีที่แล้ว

    Felt great watching this

  • @stefanwille1922
    @stefanwille1922 ปีที่แล้ว

    Great Tutorial! Thank you so much!

  • @jamesmasonic
    @jamesmasonic 3 ปีที่แล้ว +1

    Hello I will receive a hardware which has native Python API to communicate through USB. Can I embed this in C# application and communicate through it? So in my case the Python engine should receive data from USB port and transfer it to C# or send data to USB device from C# to Python and then to the device. Is that also possible?

    • @Orell1986
      @Orell1986  3 ปีที่แล้ว

      hi, yes, I expect it to work both to transfer and receive data. I've used it in much more complex scenarios than the demo in this video. The hardest part is just setting things up.

  • @Silladeruedas-m6e
    @Silladeruedas-m6e ปีที่แล้ว

    hi, i've having problems when trying to show the histogram, always throws the error: no module name HospitalmAPI. Any insight to help me find a solution?. thanks

    • @Orell1986
      @Orell1986  ปีที่แล้ว

      1) make sure you have followed README.md and have the PythonInstallDir set to where python3.dll is
      2) you can just run in debug mode (F5) and open PatientAgeHistogram.py
      I did a fresh checkout and the examples ran fine. If it still doesn't work, maybe post more details.

  • @hamidouakil
    @hamidouakil 2 ปีที่แล้ว

    The Pythonnet project does not compile on VS 2022

  • @yurifontoura2189
    @yurifontoura2189 4 ปีที่แล้ว +1

    Good tutorial, but... I'm trying so hard for a long time to import a py file, with a custom function that I wat to call from c# but still don't get close. I don't know if it is even possible. So frustrating...

    • @Orell1986
      @Orell1986  4 ปีที่แล้ว +2

      Its possible. What is the problem/error exactly?
      For example:
      using (Py.GIL())
      {
      dynamic sys = Py.Import(@"mymodule");
      }
      the above only works if mymodule.py is in the PATH. My guess is that's your issue.

    • @yurifontoura2189
      @yurifontoura2189 4 ปีที่แล้ว +1

      @@Orell1986 Really thank you man! You just saved my project. I was trying to import a file outside de PATH. But, even inside the PATH, I was putting my .py inside a directory and IDK why but when I put outside de directory but in the PATH it works.
      Thank you, best regards.

  • @behroozamirinejad3959
    @behroozamirinejad3959 3 ปีที่แล้ว

    Unfortunately I`m getting this error: Unable to load DLL 'python37': The specified module could not be found.
    How can I figure it out?

    • @Orell1986
      @Orell1986  3 ปีที่แล้ว

      Install Python 3.7. If already installed, make sure its in your path. The PythonNet version from the example targets python 3.7.

    • @behroozamirinejad3959
      @behroozamirinejad3959 3 ปีที่แล้ว

      @@Orell1986 I have installed but these error are raising: + InnerException {"Did you forget to set Runtime.PythonDLL? See github.com/pythonnet/pythonnet#embedding-python-in-net"} System.Exception {System.MissingMethodException}

    • @Orell1986
      @Orell1986  3 ปีที่แล้ว

      @@behroozamirinejad3959 Try to use a program like process monitor to make sure the dlls are loaded from where you think they are.

    • @Orell1986
      @Orell1986  2 ปีที่แล้ว

      @UCtLq3jlgwBgIffPvOR_pCdw I should update the snake hospital demo so that PATH, PYTHONHOME and PYTHONPATH are read from a settings file. If you set these variables directly, the problem should go away. Check this for more info: github.com/pythonnet/pythonnet/wiki/Using-Python.NET-with-Virtual-Environments

    • @Orell1986
      @Orell1986  2 ปีที่แล้ว

      I've added a config file which points to where Python is expected to be found. Check out the latest in the repository mentioned in the description.

  • @TheGoldenPro
    @TheGoldenPro 3 ปีที่แล้ว

    I don't know much about c# but what will happen once you compile your c# application. Will it then be able to run python code with out python installed.

    • @Orell1986
      @Orell1986  3 ปีที่แล้ว

      No, Python needs to be installed and the Path to the installation set. You can even zip Python and then deploy that with your application and actually, that is what we do with our scientific application where I work.

    • @TheGoldenPro
      @TheGoldenPro 3 ปีที่แล้ว

      @@Orell1986 oh nice to know, thanks.

  • @ernie_hudds
    @ernie_hudds 4 หลายเดือนก่อน

    Why would you even bother building PythonNet from source? I'm confused.

  • @bleuthner
    @bleuthner 7 หลายเดือนก่อน

    Really an expert! But unfortunately a poor sound quality, - hard to understand!

  • @HarshitaPrajapati-h5i
    @HarshitaPrajapati-h5i ปีที่แล้ว

    Great

  • @sunilanthony17
    @sunilanthony17 4 ปีที่แล้ว

    This is pretty cool but a bit complicated. This is something I'm looking into doing. I want to utilize the python language while building my .net core application because I want to utilize some python library such as NumPy, Pillow and etc.

    • @Orell1986
      @Orell1986  4 ปีที่แล้ว

      Agree it's complicated but the reward for integrating Python libraries is well worth the time and effort in my opinion. Thanks for watching!

    • @girimpr
      @girimpr 4 ปีที่แล้ว

      I tried pip install pythonnet but getting an error saying ask admin to install it. Any idea why?

    • @Orell1986
      @Orell1986  4 ปีที่แล้ว +3

      @@girimpr I assume you are not able to start a cmd prompt as an admin. Pip will try to write to the SitePackages folder in your Python installation directory. My guess is your Python installation folder is at some location Pip cannot write to. There are a few articles online on how to install Python without administrative rights such as towardsdatascience.com/how-to-use-python-without-administrative-right-at-your-workplace-a50ee2ee2267 . I don't know more without more details from you.

    • @sunilanthony17
      @sunilanthony17 4 ปีที่แล้ว

      @@girimpr run the application with admin privileges.

    • @girimpr
      @girimpr 4 ปีที่แล้ว

      V1 Software yeah at my office place km trying to install. Let me check the article and come.back. Thank much