Beginner Windows and Python question

Hi

Sorry if the answer is obvious, but I can’t seem to get anywhere.

I’m on Windows (because that’s what the hospital have available for me at the moment). I’ve installed Orthanc 64 bit, Python 64 bit and the pre-built Python plugin. Both Python and the plugin are version 3.7 (though I also tried 3.8). When I start Orthanc it sees the plugin and correctly loads my script from the directory given in the config. But then it never seems to run the script. I’ve tried various things, including nonsense that should throw an error, but even with verbose turned on I don’t see anything from my script. Just the usual python importers.

Are there any known issues on Windows? I’m trying to get a linux option sorted, or else get docker desktop but there are hurdles for those.

Kind regards

Jonathan

Jonathan Cole

Principal Physicist

Royal Free Hospital, London

Hi Jonathan,

I think that would help if you could share your scripts (and logs) :wink: .

Also note that, under Windows, you won’t see the python print statements in the logs. You should use orthanc.LogInfo() or orthanc.LogWarning() instead.

HTH,

Alain

Hi

My current script is:

import orthanc

orthanc.LogInfo(“Hello world”)

I’ve tried various different things though and none seem to work.

Logs:

W1116 09:31:20.735008 main.cpp:1956] Orthanc version: 1.9.7

W1116 09:31:20.735008 OrthancConfiguration.cpp:117] Scanning folder “Configuration” for configuration files

W1116 09:31:20.735008 OrthancConfiguration.cpp:66] Reading the configuration from: “Configuration\indexer.json”

W1116 09:31:20.750667 OrthancConfiguration.cpp:66] Reading the configuration from: “Configuration\orthanc.json”

W1116 09:31:20.771843 OrthancConfiguration.cpp:66] Reading the configuration from: “Configuration\python.json”

W1116 09:31:20.771843 OrthancConfiguration.cpp:66] Reading the configuration from: “Configuration\serve-folders.json”

W1116 09:31:21.019419 main.cpp:878] Loading plugin(s) from: C:\Program Files\Orthanc Server\Plugins

W1116 09:31:21.103776 PluginsManager.cpp:269] Registering plugin ‘connectivity-checks’ (version 1.9.7)

W1116 09:31:21.372728 PluginsManager.cpp:269] Registering plugin ‘gdcm’ (version 1.4)

W1116 09:31:21.372728 PluginsManager.cpp:168] Version of GDCM: 3.0.8

W1116 09:31:21.372728 PluginsManager.cpp:168] GDCM throttling is disabled

W1116 09:31:21.450900 PluginsManager.cpp:269] Registering plugin ‘indexer’ (version 1.0)

W1116 09:31:21.450900 PluginsManager.cpp:168] OrthancIndexer is disabled

W1116 09:31:21.589056 PluginsManager.cpp:269] Registering plugin ‘python’ (version 3.4)

W1116 09:31:21.589056 PluginsManager.cpp:168] Python plugin is initializing

W1116 09:31:21.589056 PluginsManager.cpp:168] Using Python script “orthanc.py” from directory: C:\Program Files\Orthanc Server

W1116 09:31:21.589056 PluginsManager.cpp:168] Program name: C:\Program Files\Orthanc Server\Orthanc.exe

W1116 09:31:21.888633 PluginsManager.cpp:269] Registering plugin ‘serve-folders’ (version 1.9.7)

W1116 09:31:21.888633 PluginsManager.cpp:168] ServeFolders: Empty configuration file: No additional folder will be served!

W1116 09:31:21.888633 OrthancInitialization.cpp:358] SQLite index directory: “C:\Orthanc”

W1116 09:31:21.904287 OrthancInitialization.cpp:457] Storage directory: “C:\Orthanc”

W1116 09:31:21.904287 HttpClient.cpp:1176] HTTPS will use the CA certificates from this file: C:\Program Files\Orthanc Server\Configuration\ca-certificates.crt

W1116 09:31:21.904287 LuaContext.cpp:93] Lua says: Lua toolbox installed

W1116 09:31:21.904287 LuaContext.cpp:93] Lua says: Lua toolbox installed

W1116 09:31:21.904287 ServerContext.cpp:478] Disk compression is disabled

W1116 09:31:21.904287 ServerIndex.cpp:391] No limit on the number of stored patients

W1116 09:31:21.904287 ServerIndex.cpp:411] No limit on the size of the storage area

W1116 09:31:21.904287 ServerContext.cpp:220] Reloading the jobs from the last execution of Orthanc

W1116 09:31:21.904287 JobsEngine.cpp:271] The jobs engine has started with 2 threads

W1116 09:31:21.904287 main.cpp:1263] DICOM server listening with AET ORTHANC on port: 4242

W1116 09:31:21.904287 HttpServer.cpp:1992] HTTP compression is enabled

W1116 09:31:21.904287 main.cpp:1138] Remote LUA script execution is disabled

W1116 09:31:21.904287 HttpServer.cpp:1769] HTTP server listening on port: 8042 (HTTPS encryption is disabled, remote access is not allowed)

W1116 09:31:21.904287 main.cpp:890] Orthanc has started

W1116 09:34:23.886102 main.cpp:952] Orthanc is stopping

W1116 09:34:24.023947 main.cpp:1170] HTTP server has stopped

W1116 09:34:24.540370 main.cpp:1279] DICOM server has stopped

W1116 09:34:24.772335 JobsEngine.cpp:312] The jobs engine has stopped

W1116 09:34:25.156934 PluginsManager.cpp:219] Unregistering plugin ‘connectivity-checks’ (version 1.9.7)

W1116 09:34:25.156934 PluginsManager.cpp:219] Unregistering plugin ‘gdcm’ (version 1.4)

W1116 09:34:25.172528 PluginsManager.cpp:219] Unregistering plugin ‘indexer’ (version 1.0)

W1116 09:34:25.172528 PluginsManager.cpp:168] Folder indexer plugin is finalizing

W1116 09:34:25.172528 PluginsManager.cpp:219] Unregistering plugin ‘python’ (version 3.4)

W1116 09:34:25.172528 PluginsManager.cpp:168] Python plugin is finalizing

W1116 09:34:25.172528 PluginsManager.cpp:219] Unregistering plugin ‘serve-folders’ (version 1.9.7)

W1116 09:34:25.172528 main.cpp:2044] Orthanc has stopped

Hi Jonathan,

You should try with orthanc.LogWarning() instead or increase the verbosity of your logs to “verbose”: https://book.orthanc-server.com/faq/log.html

HTH

Alain

Thanks. Unfortunately that’s not made any difference.

I don’t think the Python script is actually running. I think I’ve got compatible versions, but is there anything else I should be looking out for?

Jonathan

The plugin seems ok and tries to load your script:

W1116 09:31:21.589056 PluginsManager.cpp:168] Python plugin is initializing

W1116 09:31:21.589056 PluginsManager.cpp:168] Using Python script “orthanc.py” from directory: C:\Program Files\Orthanc Server

Maybe you should try to move the script to another folder ? FYI, here’s what I have on my side with your script:

“PythonScript”: “c:\Users\Alain\Downloads\orthanc.py”,

with this script content:

import orthanc
orthanc.LogWarning(“Hello world”)

and then, my logs:

W1117 08:29:31.827634 PluginsManager.cpp:269] Registering plugin ‘python’ (version 3.1)
W1117 08:29:31.827634 PluginsManager.cpp:168] Python plugin is initializing
W1117 08:29:31.827634 PluginsManager.cpp:168] Using Python script “orthanc.py” from directory: c:\Users\Alain\Downloads
W1117 08:29:31.827634 PluginsManager.cpp:168] Program name: C:\Program Files\Orthanc Server\Orthanc.exe
W1117 08:29:31.842640 PluginsManager.cpp:168] Hello world
W1117 08:29:31.843640 PluginsManager.cpp:269] Registering plugin ‘tcia’ (version 1.0)

HTH,

Alain