Installing additional python packages for orthanc-python docker image

Hello,
Sorry if this is a basic question. I’m using the orthanc-python docker image as a starting point and am trying to install additional python packages (e.g., pymongo) that my python script needs. See my dockerfile and docker-compose.yml file below. When I go to build the new docker image I get an error:

Service ‘orthanc’ failed to build : The command ‘/bin/sh -c pip3 install pymongo’ returned a non-zero code: 127

I launched the container without the RUN pip3… command in the dockerfile and poked around the files in the container. I can’t find the pip3 binary anywhere. How can I install additional python packages?

Thanks in advance for any help!
Justin

dockerfile
FROM jodogne/orthanc-python

COPY newImagesArrived.py /etc/orthanc/newImagesArrived.py
COPY orthanc.json /etc/orthanc/orthanc.json
RUN pip3 install pymongo

docker-compose.yml
version: ‘3.1’ networks: default: external: name: metis_default volumes: orthanc-image-storage: services: orthanc: build: . container_name: orthanc hostname: orthanc restart: always expose: - “4242” - “8042” env_file: - ./docker-compose.env volumes: - orthanc-image-storage:/var/lib/orthanc/db

version: ‘3.1’
networks:
default:
external:
name: metis_default
volumes:
orthanc-image-storage:
services:
orthanc:
build: .
container_name: orthanc
hostname: orthanc
restart: always
expose:

  • “4242”
  • “8042”
    env_file:
  • ./docker-compose.env
    volumes:
  • orthanc-image-storage:/var/lib/orthanc/db

It may be that the jodogne/orthanc-python image doesn’t come with PIP3 installed. I usually use the Osimis images, and I think those come with python and pip built-in:

See: https://bitbucket.org/osimis/orthanc-builder/src/master/docker/orthanc-runner-base/Dockerfile

You might be able to just install PIP3 by adding something like what is below to your Docker File:

RUN export DEBIAN_FRONTEND=noninteractive &&
apt-get --assume-yes update &&
apt-get --assume-yes install python3-pip

Thank you! That worked like a charm. Much appreciated.

Justin

The “sdcotti”-solution did not work for me. My workaround is to have a

import sys
sys.path.append("/path/to/my/own/venv/site-packages")
import torch

block in my python script (solution from official doc)