I am fairly new to docker, and I am trying to make a docker image which gives me jupyter server with pyvips. The building of the image and running the container is going fine. Accessing the jupyterlab, including "import pyvips" in the notebook is working fine. However, when I try to use the "dzsave"-method there is an error concerning:
"no such operation dzsave"
"VipsOperation: class 'dzsave' not found"
This works fine in the notebook:
import pyvips img = pyvips.Image.new_from_file('my_wsi.svs')
This throws an exception:
img.dzsave('my_tiles')
I am using a dockerfile from: https://github.com/jupyter/docker-stacks/blob/main/images/scipy-notebook/Dockerfile My edits in order to add pyvips ("libvips-dev" and "pyvips") are marked with "**" in the docker file text below.
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
ARG REGISTRY=quay.io
ARG OWNER=jupyter
ARG BASE_CONTAINER=$REGISTRY/$OWNER/minimal-notebook
FROM $BASE_CONTAINER
LABEL maintainer="Jupyter Project <[email protected]>"
# Fix: https://github.com/hadolint/hadolint/wiki/DL4006
# Fix: https://github.com/koalaman/shellcheck/wiki/SC3014
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
USER root
RUN apt-get update --yes && \
apt-get install --yes --no-install-recommends \
# for cython: https://cython.readthedocs.io/en/latest/src/quickstart/install.html
build-essential \
**libvips-dev \**
# for latex labels
cm-super \
dvipng \
# for matplotlib anim
ffmpeg && \
apt-get clean && rm -rf /var/lib/apt/lists/*
USER ${NB_UID}
# Install Python 3 packages
RUN mamba install --yes \
'altair' \
'beautifulsoup4' \
'bokeh' \
'bottleneck' \
'cloudpickle' \
'conda-forge::blas=*=openblas' \
'cython' \
'dask' \
'dill' \
'h5py' \
'ipympl'\
'ipywidgets' \
'jupyterlab-git' \
'matplotlib-base' \
'numba' \
'numexpr' \
'openpyxl' \
'pandas' \
'patsy' \
'protobuf' \
**'pyvips' \ **
'pytables' \
'scikit-image' \
'scikit-learn' \
'scipy' \
'seaborn' \
'sqlalchemy' \
'statsmodels' \
'sympy' \
'widgetsnbextension'\
'xlrd' && \
mamba clean --all -f -y && \
fix-permissions "${CONDA_DIR}" && \
fix-permissions "/home/${NB_USER}"
# Install facets package which does not have a `pip` or `conda-forge` package at the moment
WORKDIR /tmp
RUN git clone https://github.com/PAIR-code/facets && \
jupyter nbclassic-extension install facets/facets-dist/ --sys-prefix && \
rm -rf /tmp/facets && \
fix-permissions "${CONDA_DIR}" && \
fix-permissions "/home/${NB_USER}"
# Import matplotlib the first time to build the font cache
RUN MPLBACKEND=Agg python -c "import matplotlib.pyplot" && \
fix-permissions "/home/${NB_USER}"
USER ${NB_UID}
WORKDIR "${HOME}"`
You are installing ubuntu's libvips, but then installing pyvips with mamba. They have their own mostly broken libvips binary which is missing dzsave.
I wouldn't use mamba. Systems like this can be useful on windows, where installing the correct binary for a python package is often tricky, but on linux systems it's almost always much safer and more reliable to use the system binaries.
I tried this dockerfile:
Then ran: