Getting Access to Python Plugin in Windows Service

When I start the windows service without using python plugin, the Orthanc perfectly starts as a service. Below is the configuration when it runs perfectly fine:

Screenshot_20221215_183847.png

But as soon as I add the python plugin, Orthanc fails to start as a service. Below is the configuration for the same:
Screenshot_20221215_183858.png

I guess, Orthanc is unable to access the Python interpreter. Could you please help me with this problem.

Thank you so much in advance!

Hi,

First, make sure you have followed all recommendations from here:

Beware that one version of the Python plugin can only be run against one version of the Python interpreter. This version is clearly indicated in the filename of the precompiled binaries.

Pay also attention to pick the right 32/64 bits version. If you are running Orthanc 64bits, install Python in 64bits and select the 64bits Python plugin too.

When you install Python on your Windows machine, make sure to install Python for All Users and select the Add Python to Path option.

Then, check your logs for errors and share your logs.

Best regards,

Alain.

Screenshot_20221215_183847.png

Screenshot_20221215_183858.png

Hi Alain,

I have made sure all the points you have mentioned:

  • I have installed Python for all users
  • It’s 64 bits
  • Checked add to Path option while installation
  • Orthanc version is 4.0
  • Python version is 3.8.10
  • Python Plugin which I have downloaded is OrthancPython3.8-4.0.dll which is the compatible one
    And like I already said, it runs perfectly fine when I operate it from my terminal using command “Orthanc.exe configuration.json”

It doesn’t work as expected when we start it as windows service. For running the service, I have used nssm.exe.

Paths of nssm.exe have been configured and that also works fine if I run manually but again fails when I run as a service!

Quick response will be appreciated. Thanks!

Screenshot_20221215_183847.png

Screenshot_20221215_183858.png

Then you should use ProcessMonitor to check what’s going wrong. Please share your findings to help future visitors.

Screenshot_20221215_183847.png

Screenshot_20221215_183858.png

Can you please check if the user you are running orthanc manually and the one starting the orthanc service are same.

Try this -

  • open terminal/cmd and type python -V
  • note down python version

Now open terminal as admin and

  • python -V
  • note down python version

Are both python versions same and matching your python plugin version ?

I really appreciate the response but unfortunately that doesn’t help. I have checked the Orthanc command in noth manual process and in service, they are both.

Also the python versions are the same for user as well as admin. Also I have only one version of Python installed in my system which is 3.8.10. Attaching ss for your reference!

Screenshot_20221216_145348.png

Screenshot_20221216_145409.png

Please help if you have some other things/solutions on mind!

FYI, here’s the kind of output you may get with ProcessMonitor that would help you diagnose what goes wrong when loading the python plugin (here, I intentionally prevented access to the dll for the SYSTEM user)

image.png

Screenshot_20221216_145348.png

Screenshot_20221216_145409.png

Hi Alain,

That really helped me check the process for the service. I am still not familiar, how do I figure out the exact problem because all I see is success and NAME_NOT_FOUND. Attaching screenshot for your reference!

Screenshot_20221216_152115.png

Screenshot_20221216_145348.png

Screenshot_20221216_145409.png

image.png

Filter on Orthanc.exe process and check for DLL loading. Like shown in my screenshot.

Screenshot_20221216_145348.png

Screenshot_20221216_145409.png

image.png

Screenshot_20221216_152115.png

Different users can lead to wildly different runtime environments.

My advice would be to check if the service works fine when run as the same BadBoy (cool user name btw) user. Google for “change windows service to run as user”

Example: https://docs.microfocus.com/SM/9.61/Hybrid/Content/serversetup/tasks/configure_the_service_manager_service_to_run_as_a_windows_user.htm

The service is run as the SYSTEM account, which has some limitations, and its PATH is probably different from the BadBoy user.

That would be investigation step #1 if I were you.

Thanks Benjamin and Alain! Those resources really helped me gain more knowledge towards Orthanc and windows services.

However, I got to know, it was the firewall which was creating the issues.The process and the steps were followed perfectly fine!

Thanks Benzy for mentioning the user name. I hope this thread helps more users on the platform. Cheers!

Hello,

For reference, I have added this information to the Orthanc Book:
https://book.orthanc-server.com/faq/troubleshooting.html#windows-specific-issues

Regards,

Sébastien-