Hi!
I know that several topics have been created on this, and I believe I have attempted to follow all the suggestions they provided. However, I still cannot seem to load Python scripts for the life of me.
Please help me understand what I’m doing wrong.
Orthanc.json
jj.py is just rest.py from documentation
Logs:
W0301 10:56:09.152420 PluginsManager.cpp:261] Registering plugin ‘python’ (version mainline)
W0301 10:56:09.152420 PluginsManager.cpp:157] Python plugin is initializing
E0301 10:56:09.152420 PluginsManager.cpp:153] Inexistent directory for the Python script: C:\Program Files\Orthanc Server\jj.py
E0301 10:56:09.152420 PluginsManager.cpp:91] Error while initializing plugin C:\Program Files\Orthanc Server\Plugins\OrthancPython-Python3.11-mainline.dll (code -1)
Thanks for clarifying. I just added python.path as a last-ditch effort to provide a path hoping maybe that would help. Got the idea from this log
W0301 12:46:15.687176 PluginsManager.cpp:261] Registering plugin ‘python’ (version mainline)
W0301 12:46:15.687176 PluginsManager.cpp:157] Python plugin is initializing
W0301 12:46:15.687176 PluginsManager.cpp:157] Options “PythonScript” and “Python.Path” are not provided: Python scripting is disabled
The .py file is there and I have tried changing its name, location to different folders and drives thinking maybe it’s a permission issue but nothing works
What I learned:
The encountered issue stems from a dual setup of user and system-level site packages installations. When Orthanc crashes while loading a script, two logs are generated; examine the Python error logs for insights. The problem may arise from Orthanc’s search for packages in the system site-packages folder. One resolution is to run Orthanc at the user level, though challenges may be encountered. To address the issue, a workaround involves importing global packages first, then specifying the user-level site-packages folder location and importing the remaining packages. The provided code snippet demonstrates this approach:
import sys
import orthanc
sys.path.append(r’C:\Users\user\AppData\Roaming\Python\Python311\site-packages’)
from PIL import Image
import imagehash
import numpy as np