Dockerising SNAP + Snappy (Python 3.6)

Hi folks,

I’ve done a bit of searching and couldn’t find anything that looked like someone had got SNAP + Snappy setup with Python 3.6.

I’m working on a project where I’m hoping to dockerise snappy in particular for cloud-based processing.

Currently my Dockerfile looks like so:

FROM ubuntu:bionic-20200311

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
    apt-get install -y build-essential curl gcc git libbz2-dev libffi-dev liblzma-dev \
    libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev libssl-dev llvm make \
    openjdk-8-jdk python3.6 python-openssl python3-distutils tk-dev wget xz-utils zlib1g-dev

ENV JDK_HOME /usr/lib/jvm/java-8-openjdk-amd64/
ENV JAVA_HOME $JDK_HOME
RUN export JDK_HOME
RUN export JAVA_HOME

RUN wget http://step.esa.int/downloads/7.0/installers/esa-snap_sentinel_unix_7_0.sh
RUN chmod +x esa-snap_sentinel_unix_7_0.sh
RUN ./esa-snap_sentinel_unix_7_0.sh -q

RUN /usr/local/snap/bin/snappy-conf $(which python)

When the last line runs, I get the following:

/usr/local/snap/bin/../platform/lib/nbexec: WARNING: environment variable DISPLAY is not set
Configuring SNAP-Python interface...
java.io.IOException: Python configuration failed.
Command [/usr/bin/python ./snappyutil.py --snap_home /usr/local/snap --java_module /usr/local/snap/snap/modules/org-esa-snap-snap-python.jar --force --log_file ./snappyutil.log --jvm_max_mem 8G --java_home /usr/local/snap/jre --req_arch amd64]
failed with return code 30.
Please check the log file '/root/.snap/snap-python/snappy/snappyutil.log'.
        at org.esa.snap.python.PyBridge.configureJpy(PyBridge.java:232)
        at org.esa.snap.python.PyBridge.installPythonModule(PyBridge.java:149)
        at org.esa.snap.rcp.cli.SnapArgsProcessor.processPython(SnapArgsProcessor.java:103)
        at org.esa.snap.rcp.cli.SnapArgsProcessor.process(SnapArgsProcessor.java:49)
        at org.netbeans.modules.sendopts.DefaultProcessor.process(DefaultProcessor.java:202)
        at org.netbeans.spi.sendopts.Option$1.process(Option.java:387)
        at org.netbeans.api.sendopts.CommandLine.process(CommandLine.java:317)
        at org.netbeans.modules.sendopts.HandlerImpl.execute(HandlerImpl.java:62)
        at org.netbeans.modules.sendopts.Handler.cli(Handler.java:69)
        at org.netbeans.CLIHandler.notifyHandlers(CLIHandler.java:234)
        at org.netbeans.core.startup.CLICoreBridge.cli(CLICoreBridge.java:82)
        at org.netbeans.CLIHandler.notifyHandlers(CLIHandler.java:234)
        at org.netbeans.CLIHandler$1.exec(CLIHandler.java:268)
        at org.netbeans.CLIHandler.finishInitialization(CLIHandler.java:447)
        at org.netbeans.MainImpl.finishInitialization(MainImpl.java:256)
        at org.netbeans.Main.finishInitialization(Main.java:92)
        at org.netbeans.core.startup.Main.start(Main.java:316)
        at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:123)
        at java.lang.Thread.run(Thread.java:748)
Python configuration error: Python configuration failed.
Command [/usr/bin/python ./snappyutil.py --snap_home /usr/local/snap --java_module /usr/local/snap/snap/modules/org-esa-snap-snap-python.jar --force --log_file ./snappyutil.log --jvm_max_mem 8G --java_home /usr/local/snap/jre --req_arch amd64]
failed with return code 30.
Please check the log file '/root/.snap/snap-python/snappy/snappyutil.log'.

If I cat the log file:

INFO: Installing from Java module '/usr/local/snap/snap/modules/org-esa-snap-snap-python.jar'
WARNING: Architecture requirement possibly not met: Python is x86_64 but JVM requires amd64
INFO: Installing jpy...
INFO: Extracting 'lib/jpy-0.9.0-cp27-cp27mu-linux_x86_64.whl' from '/usr/local/snap/snap/modules/org-esa-snap-snap-python.jar'
INFO: Unzipping '/root/.snap/snap-python/snappy/lib/jpy-0.9.0-cp27-cp27mu-linux_x86_64.whl'
INFO: Configuring jpy...
INFO: jpy Python API configuration written to '/root/.snap/snap-python/snappy/jpyconfig.py'
INFO: jpy Java API configuration written to '/root/.snap/snap-python/snappy/jpyconfig.properties'
INFO: Configuring snappy...
INFO: snappy configuration written to '/root/.snap/snap-python/snappy/snappy.ini'
INFO: Importing snappy for final test...
ERROR: Configuration failed with exit code 30

Not too sure where to go from here in trying to get this working. I have found https://github.com/schwankner/esa-snap-with-python which looked promising, but this is still Python 2, the PR for Python 3 seems dormant.

If anyone has any pointers, or has been trying the same thing, any input is appreciated!

Cheers,

Ciaran

Did you find any solution to this? I am using python 2.7 and got the same error message in log.

I haven’t no, was hoping something would pop up here!

OK. Thanks.

On Ubuntu bionic or Mint 19, SNAP + Snappy setup with Python 3.6 just works, so there isn’t much need to post on the internet.

I have snappy working in a Linux Mint 19 (based on bionic) VM, using the SNAP jre and Python 3.6, but it isn’t headless. Try replacing openjdk-8-jdk with openjdk-8-jre-headless and running snappy-conf.py with options to force your choice of JRE.

It looks like snappy-conf ignored your settings chose SNAP 's JRE (e.g.,snap_home/jre):

/usr/bin/python ./snappyutil.py --snap_home /usr/local/snap 
--java_module /usr/local/snap/snap/modules/org-esa-snap-snap-python.jar 
--force --log_file ./snappyutil.log --jvm_max_mem 8G 
--java_home /usr/local/snap/jre --req_arch amd64

You could play around with this command in the .snap/snap-python/snappy directory.

Awesome, thanks for the suggestion! I will give it a go and put an update here.

Appreciate it!

I had the same issue a few days ago. You can check my solution on Docker Hub:

Python 3.6.10:
https://hub.docker.com/repository/docker/deltodon/esa-snap-cpython

Jupyter Lab
https://hub.docker.com/repository/docker/deltodon/esa-snap-jupyter

I hope that helps.

1 Like