Question
· Oct 2

Python.net Install

This is for IRIS For Health 2024.2.0

We are migrating away from the .NET Gateway and trying to use the python integration instead.

I followed the instructions to install IRIS

Then I installed python following the IRIS documentation indicating that python should be installed globally.

I set up the PythonRuntimeLibrary and PythonRuntimeLibraryVersion options under System->Configuration->Advanced memory settings and when I run the shell function, I get python:

USER>do ##class(%SYS.Python).Shell()
 
Python 3.12.6 (tags/v3.12.6:a4a2d2b, Sep  6 2024, 20:11:23) [MSC v.1940 64 bit (AMD64)] on win32
Type quit() or Ctrl-D to exit this shell

To reach out to our C# DLL, I ran the following command to install python.net

pip install pythonnet, it reported downloading items succuessfully.

To test, I have a simple python script that is just "import clr" and when I run this from the cmd prompt, it does not error out. I did make a demo DLL with a namespace, class, and one function. If I reference that DLL, it calls the function and prints hello world. So, it appears to me that python.net is working.

 

But when I create a new class and have 'import clr" in the classmethod with Language = python, I am getting this error:

USER>d ##class(User.Test).Check()
 
D ##CLASS(User.Test).Check()
^
<THROW> *%Exception.PythonException <PYTHON EXCEPTION> 246 <class 'RuntimeError'>: Failed to initialize Python.Runtime.dll

 

From my reading, I'm pretty sure its a path issue of some kind because I don't have the right environment variables set up.

I tried adding in all of these lines into the classmethod before I call import clr, and none of them have helped.

os.environ["PYTHONPATH"] = r"C:\Program Files\Python312\Lib\site-packages"

os.environ["PYTHONNET_PYDLL"] = r"C:\Program Files\Python312\python312.dll"

 

Has anyone else gotten python.net to work with IRIS?

$ZV: IRIS for Windows (x86-64) 2024.2 (Build 247U) Tue Jul 16 2024 09:52:30 EDT
Discussion (0)1
Log in or sign up to continue