Problem installing snappy on linux

Hey everyone I’m unfortunately having problems installing snappy. Due to Corona i have an access to a computer pool at my university which has a Linux system.

My python version is in the environment ‚milena_2‘: 3.6.12
Location of snappy-conf: /home/milena/esa/bin
Assumed location of python.exe found with ‚which python‘: /home/milena/.conda/envs/milena_2/bin/python/

My steps:

  1. Enter the computer pool
  2. Activate the conda environment with python version 3.6.12
  3. Go to location of snappy-conf file: cd /home/milena/esa/bin
  4. ./snappy-conf /home/milena/.conda/envs/milena_2/bin/python/

Here is the source code:

(milena_2) milena@pcpool4:~/esa/bin$ ./snappy-conf /home/milena/.conda/envs/milena_2/bin/python/

/home/milena/esa/bin/…/platform/lib/nbexec: WARNING: environment variable DISPLAY is not set

Configuring SNAP-Python interface…

java.io.IOException: Python configuration failed.

Command [/home/milena/.conda/envs/milena_2/bin/python ./snappyutil.py --snap_home /home/milena/esa --java_module /home/milena/esa/snap/modules/org-esa-snap-snap-python.jar --force --log_file ./snappyutil.log --java_home /home/milena/esa/jre --req_arch amd64]

failed with return code 10.

Please check the log file ‘/home/milena/.snap/snap-python/snappy/snappyutil.log’.

at org.esa.snap.python.PyBridge.configureJpy(PyBridge.java:223)

at org.esa.snap.python.PyBridge.installPythonModule(PyBridge.java:147)

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:745)

Python configuration error: Python configuration failed.

Command [/home/milena/.conda/envs/milena_2/bin/python ./snappyutil.py --snap_home /home/milena/esa --java_module /home/milena/esa/snap/modules/org-esa-snap-snap-python.jar --force --log_file ./snappyutil.log --java_home /home/milena/esa/jre --req_arch amd64]

failed with return code 10.

Please check the log file ‘/home/milena/.snap/snap-python/snappy/snappyutil.log’.

Can anyone help me out? Thanks a lot in advance!

Your command line: $ ./snappy-conf /home/milena/.conda/envs/milena_2/bin/python/
has a forward slash at the end. What do you get for $ /home/milena/.conda/envs/milena_2/bin/python --version? (no trailing .). If this gives
Python 3.6.12 then $ ./snappy-conf /home/milena/.conda/envs/milena_2/bin/python should work. If not you need to find the location of the python 3.6.12 program.

Thanks for the quick reply! I unfortunately still get the same code as i send here. I anyways tried out to import snappy, but the Jupiter notebook still shows me that it doesn’t exist.

Have you been able to run the simple tests from Configure Python to use the SNAP snappy Python interface? At the end of that document there are some examples showing how to ensure that Python can find SNAP snappy. Although one suggestion is to copy snappy to a system Python directory, I don’t recomment that as there are multiple Python libraries called snappy which other Python applications may require. Try this version of the example (with USERPROFILE replaced by HOME for MacOS (and linux):

import os
snappy_envar = 'HOME'
envs = os.environ
if not snappy_envar in envs.keys():
    raise Exception('Can’t find snappy')
else:
    snappy_dir = os.path.join(envs.get(snappy_envar), '.snap', 'snap-python')
sys.path.append(snappy_dir)
import snappy

I haven’t gotten anywhere yet, so i asked my supervisor for help. He thinks to have found the bug, which is the missing jpy. Do you maybe know which java version for jdk has to be used for snappy?

Thanks a lot in advance!

Here is the error he keeps getting:

(base) administrator@pcpool4:/home/milena/esa/bin/jpy$ python3.6

setup.py bdist_wheel
running bdist_wheel
running build
running build_py
creating build
error: could not create ‘build’: Permission denied
(base) administrator@pcpool4:/home/milena/esa/bin/jpy$ sudo python3.6
setup.py bdist_wheel
[sudo] password for administrator:
Error: environment variable “JAVA_HOME” must be set to a JDK (>= v1.7)
installation directory

Using sudo" as in (base) administrator@pcpool4:/home/milena/esa/bin/jpy$ sudo python3.6 usually causes a growing cascade of problems because you end up with files that aren’t accessible to a regular user.

I don’t see mention of your OS details and SNAP version. The snappy configuration didn’t change from the last update of SNAP 7 to SNAP 8.0. If you have an older SNAP version you should update it.

The standard method (Configure Python to use the SNAP snappy Python interface) with a python 3.6 environment will install jpy. Are you able to run the simple examples?

You may need to undo damage done with “sudo” by resetting permissions that were changed.

Here is a small test to run in a Jupyter notebook (assuming snappy is in the location mentioned in the above document):

import os
import sys
print(sys.version)
snappy_envar='HOME'
if sys.platform == 'win32':
    snappy_envar = 'USERPROFILE'
envs = os.environ
if not snappy_envar in envs.keys():
    raise Exception('Can’t find snappy')
else:
    snappy_dir = os.path.join(envs.get(snappy_envar), '.snap', 'snap-python')
sys.path.append(snappy_dir)
from snappy import ProductIO
p = ProductIO.readProduct(os.path.join(snappy_dir, 'snappy','testdata','MER_FRS_L1B_SUBSET.dim'))
list(p.getBandNames())

This gives (on Windows):

3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)]
['radiance_1',
 'radiance_2',
 'radiance_3',
 'radiance_4',
 'radiance_5',
 'radiance_6',
 'radiance_7',
 'radiance_8',
 'radiance_9',
 'radiance_10',
 'radiance_11',
 'radiance_12',
 'radiance_13',
 'radiance_14',
 'radiance_15',
 'l1_flags',
 'detector_index']