Issue compiling Python Plugin, importing PIP modules, UBUNTU 20.04

I’m moving Orthanc to another system. UBUNTU 20.04. Compiled orthanc and the orthanc-python (mainline) from source. When I start up Orthanc I get the following errors. My plugin,, imports both pydicom and pdfkit. When I comment those out and restart Orthanc it starts up without error.

Orthanc version: mainline (20200830T165517)

W0830 13:32:50.306206 main.cpp:802] Loading plugin(s) from: /home/sscotti/Desktop/OrthancConfig/plugins/
W0830 13:32:50.309307 PluginsManager.cpp:269] Registering plugin ‘python’ (version mainline)
W0830 13:32:50.309342 PluginsManager.cpp:168] Python plugin is initializing
W0830 13:32:50.309691 PluginsManager.cpp:168] Using Python script “” from directory: /home/sscotti/Desktop/OrthancConfig/plugins
W0830 13:32:50.309733 PluginsManager.cpp:168] Force global loading of Python shared library: /lib/x86_64-linux-gnu/
W0830 13:32:50.309843 PluginsManager.cpp:168] Program name: /home/sscotti/Desktop/orthanc/Build/Orthanc
E0830 13:32:50.369613 PluginsManager.cpp:164] Error during the installation of the Python script, traceback:
<class ‘ModuleNotFoundError’>
No module named ‘pydicom’
File “”, line 991, in _find_and_load
File “”, line 975, in _find_and_load_unlocked
File “”, line 671, in _load_unlocked
File “”, line 783, in exec_module
File “”, line 219, in _call_with_frames_removed
File “/home/sscotti/Desktop/OrthancConfig/plugins/”, line 4, in
import pydicom
File “”, line 991, in _find_and_load
File “”, line 973, in _find_and_load_unlocked
E0830 13:32:50.369701 PluginsManager.cpp:102] Error while initializing plugin


My system has Python 3.8.2, which I think is installed by default on 20.04. When I built the plugin from source the compilation appeared to go OK.

-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") -- Checking for module 'python-3.8-embed' -- Found python-3.8-embed, version 3.8 -- Configuring done -- Generating done

pip3 list includes the two modules that I want enabled with the plugin (pdfkit and pydicom), and those were installed before building the plug-in:

pdfkit 0.6.1 pexpect 4.6.0 Pillow 7.0.0 pip 20.0.2 protobuf 3.6.1 pycairo 1.16.2 pycups 1.9.73 pydicom 2.0.0


After commenting out import pydicom an import pdfkit:

W0830 13:53:58.178403 main.cpp:802] Loading plugin(s) from: /home/sscotti/Desktop/OrthancConfig/plugins/
W0830 13:53:58.181938 PluginsManager.cpp:269] Registering plugin ‘python’ (version mainline)
W0830 13:53:58.181983 PluginsManager.cpp:168] Python plugin is initializing
W0830 13:53:58.182487 PluginsManager.cpp:168] Using Python script “” from directory: /home/sscotti/Desktop/OrthancConfig/plugins
W0830 13:53:58.182542 PluginsManager.cpp:168] Force global loading of Python shared library: /lib/x86_64-linux-gnu/
W0830 13:53:58.182781 PluginsManager.cpp:168] Program name: /home/sscotti/Desktop/orthanc/Build/Orthanc
. . . orthanc starts up


Just leaving out for now, but would like to compile with those modules enabled. Any suggestions appreciated.


Check out the attached Dockerfile and sample script.

As can be seen from this configuration, both pydicom and pdfkit work fine with Orthanc on Ubuntu 20.04.

By the way, answering your question took 1h30 of my time, just to conclude that there was no problem with Orthanc, but that it was an issue with your personal setup. You are endangering the development of Orthanc by claiming so many issues without providing minimal working examples:

Dockerfile (1.71 KB) (261 Bytes)

configuration.json (83 Bytes)

Sorry about that. It took me about that long to write the e-mail, and much longer trying various things to compile. Must be something with my UBUNTU setup, although got OS X to work finally. I’ll follow up with the fix on my UBUNTU install if I can figure that out.

I am attaching a python script file containing a number of scripts that I’ve developed, including the one using pdfkit. You have to use PIP to install the pdfkit module, and then also compile the Python Plug-in again to use that, but it does work now. Same applies for pydicom Here is a description of the scripts, the source is attached.

1. curl http://localhost:8042/pydicom/af1c0b10-c44ac936-74aa66e8-0c4463e0-2e98c65e (uuid for instance)

Demo for using Pydicom, can be extended. Bascially returns a dump2dcm.

2. curl http://localhost:8042/get-configs/ALL

Gets Orthanc config file params, all or by a particular group;

3. curl http://localhost:8042/sendemail -d ‘{“subject”:“This is a test”,“body”:“string”}’

Sends an email. Could be extended for HTML mails and other features, also callable from with the script.

4. curl http://localhost:8042/studies/page -d ‘{“Query”:{“PatientName”:““,“PatientBirthDate”:”“,“PatientSex”:”“,“PatientID”:”“,“AccessionNumber”:”“,“StudyDescription”:””,“ReferringPhysicianName”:“**”,“StudyDate”:“”},“Level”:“Study”,“Expand”:true,“MetaData”:{},“pagenumber”:1,“itemsperpage”:5,“sortparam”:“StudyDate”,“reverse”:1,“widget”:1}’


5. curl -k -X POST -d ‘[“AccessionNumber”]’ http://localhost:8042/mwl/file/delete

Deletes .wl file in the Worklists Folder, could be extended to delete multiple from array of values, the passed in param is the filename prefix

6. curl --request POST --url http://localhost:8042/mwl/file/make --data ‘{“MediaStorageSOPClassUID”:“MediaStorageSOPClassUID”,“CharSet”:“CharSet”,“AccessionNumber”:“AccessionNumber”,“Modality”:“Modality”,“RequestingPhysician”:“RequestingPhysician”,“PatientName”:“PatientName”,“PatientID”:“PatientID”,“PatientBirthDate”:“PatientBirthDate”,“PatientSex”:“PatientSex”,“MedicalAlerts”:“MedicalAlerts”,“Allergies”:“Allergies”,“AdditionalPatientHistory”:“AdditionalPatientHistory”,“StudyInstanceUID”:“StudyInstanceUID”,“RequestingPhysician”:“RequestingPhysician”,“RequestedProcedureDescription”:“RequestedProcedureDescription”,“ScheduleStationAETitle”:“ScheduleStationAETitle”,“ScheduledProcedureStepStartDate”:“ScheduledProcedureStepStartDate”,“ScheduledProcedureStepStartTime”:“ScheduledProcedureStepStartTime”,“RequestedProcedureID”:“RequestedProcedureID”,“RequestedProcedurePriority”:“RequestedProcedurePriority”}’

Creates a MWL .wl files and a .txt file in the Worlists Folder with a name equal to the Accession Number. Can be

customized to meet needs

7. curl -k http://localhost:8042/pdfkit/htmltopdf -d ‘{“html”:“This is a test”,“method”:“string”}’

Creates a PDF file from raw HTML string using wkhtmltopdf pdfkit wrapper. Requires the pip module and wkhtmltopdf installed on the system. The Python Plugin has to be compiled with that PIP module also.

8. curl -k http://localhost:8042/studies/arrayIDs -d ‘[“6efb3ff2-4cd16ca1-35cdb247-2d1c5f78-d6ba584e”,“79de0218-30258875-1adaa569-f71944db-a88eef7c”]’

Gets Array of Expanded study data for an array of uuid’s, including the instance count and modalities

9. curl -k http://localhost:8042/patient/studycounts -d ‘[“DEV0000001”,“DEV0000002”]’

Gets study counts for a patient ID, or array of ID’s (24.8 KB)

Just a comment.

I tried to add some Python scripts to: OrthancContributed - GitHub
and it looks like you have to have write privileges to add any files ?

I did separate out the one for using wkhtmltopdf into a separate file and did some testing. I’ve attached that. It is pretty well documented and has some sample HTML (escaped and including a style sheet), as well as a Base64encoded sample because it’ll also attach the generated PDF or the passed in Base64 as a series to a study if that is specified by the study uuid. It does require the wkhtmltopdf executable and dcmtk and the pdfkit Python PIP module, so there is a bit of a setup.

I found a somewhat more explicit way to compile the Python Plug-in on OS X, which works if you have several versions of Python:

cmake -DPYTHON_LIBRARY=/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/libpython3.8.dylib -DPYTHON_INCLUDE_DIR=/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/include/python3.8/ -DPYTHON_VERSION=3.8 -DSTATIC_BUILD=ON -DCMAKE_BUILD_TYPE=Release …/

Thanks for your help. (20.7 KB)


In order to interact with the “OrthancContributed” repository, you’ll have to learn about GitHub pull requests. Many tutorials are available on the Web:

I have added your instructions about Python and OS X in the Orthanc Book:

Thanks for your contributions,