Linux: Installation of snappy

I have a VM (RSS_CloudToolbox, Linux, CentOS 6.7) with SNAP (2.0.2), s2tbx and sen2cor already installed and running properly. Now I would like to run a python-script which uses snappy.

I wanted to install it as followed:

cd /home/pi/snap/bin ./snappy-conf /home/pi/anaconda2/bin/python

(As described: https://senbox.atlassian.net/wiki/display/SNAP/How+to+use+the+SNAP+API+from+Python )

But I get an unknow error message:

Did I do something wrong? What could be the problem? Do I may need administration rights?

Thanks for any help.

I have no idea what the cause might be.
Can you check if you have a snappyutil.log file in ~/.snap/snap-python. If you have it, check its content. Maybe it gives some indication.

The VM admin told me he installed SNAP with Python but I can not find the directory ~/.snap/snap-python .

However I can find a directory /home//snap/ with folders:

  • bin
  • etc
  • ide
  • jre
  • platform
  • snap
    and the files:
  • LICENSE.txt
  • SNAP Configuration Optimiser
  • SNAP Desktop
  • VERSION.txt (= 2.0.2)

If ~/.snap does not exist it means that snap never run before on that machine and also the snappy-conf did not work.
Try to run snappy-conf with an other target directory as the default.
e.g.

./snappy-conf /home/pi/anaconda2/bin/python /home/mySnappy

Thank you for your hint. I started SNAP and generated an RGB and afterward I could find the .snap directory and the log-File. There was already an ImportError:

Afterward I tried to run ./snappy-conf /home/pi/anaconda2/bin/python /home/pi/snappy1 and I got an other error:

But a folder snappy in snappy1 was created. The module snappy is still not recognized.

It seems that your CentOS is not compatible with one of the libraries snappy requires.
To be more specific GLIBC_2.14 is required by jpy which is needed by snappy.
To overcome this issue you can compile jpy on your own.
This is document on this page.

Good morning,

I tried to fix it but I don’t get it. I downloaded the jpy from GitHub and want to run this code:

export PYTHONPATH=$PYTHONPATH:build/lib-os-platform-python-version

How can I find out, which is my os-platform-python-version? I have anaconda (/home/pi/anaconda2/), but I did not find a “build” folder in it, where a folder with “lib-…” exists.

Have you already called python setup.py --maven build?
This is described in the section Build for Linux / Darwin.
The directory build/lib-<os-platform>-<python-version> should be created when calling this command

Ok, that I did not call. :sweat_smile: But there I also have an error:

cd /home/pi/snap/jpy
export JDK_HOME=
export JAVA_HOME=$JDK_HOME
python setup.py --maven build

Error: environment variable “JAVA_HOME must be set to a JDK (>= v1.7) installation directory”.

When searching for it I saw that there is only JDK 1.6 installed. And because I don’t have root permission I could not install a newer version. I will continue to work on it. :wink:

How we say it in German:
“Mühsam ernährt sich das Eichhörnchen.”
Which translates to:
“Little by little, the bird builds its nest.”

1 Like

Hahaha… guter Spruch und er passt dazu! :wink:

Good morning,

the admin team of the VM could update the required software for me and I could finally install jpy. But I still have the same error.

[pi@RSS_CloudToolbox bin]$
[pi@RSS_CloudToolbox bin]$ ./snappy-conf /home/pi/anaconda2/bin/python /home/pi/snappy
java.net.UnknownHostException: RSS_CloudToolbox: RSS_CloudToolbox: unknown error
at java.net.InetAddress.getLocalHost(InetAddress.java:1505)
at org.netbeans.CLIHandler$2.run(CLIHandler.java:667)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1423)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)
Caused by: java.net.UnknownHostException: RSS_CloudToolbox: unknown error
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323)
at java.net.InetAddress.getLocalHost(InetAddress.java:1500)
… 3 more
No protocol specified

Exception: java.lang.NoClassDefFoundError thrown from the UncaughtExceptionHandler in thread “On Start/Stop”

Exception: java.lang.NoClassDefFoundError thrown from the UncaughtExceptionHandler in thread “Folder Instance Processor”
[pi@RSS_CloudToolbox bin]$

For your information: The snappyutil.log I found was not in ~/.snap/snap-python but in ~/.snap/snap-python/snappy and when I run the code ./snappy-conf /home/pi/anaconda2/bin/python it does not write anything into the log.

In the ~/.snap/snap-python I only find the file snappy.properties which contains:

#Created by org.esa.snap.python.PyBridge
#Mon Feb 22 15:45:58 CET 2016
snap.pythonExecutable=/home/pi/anaconda2/bin/python
snap.pythonModuleDir=/home/pi/snappy1

The directory /home/pi/snappy1 does not exist anymore. If I remember right, then it was created the first time I ran ./snappy-conf /home/pi/anaconda2/bin/python /home/pi/snappy1. Should I ask the admins to re-install SNAP?

What else could be the cause?

Hi,

I proceeded a bit further with the installation of snappy on a CentOS 6.x environment, by compiling separately jpy (it required Oracle Java SDK 1.8).
After the installation, I performed the following test:

>>> from snappy import ProductIO
>>> p = ProductIO.readProduct('/tmp/snappy/testdata/MER_FRS_L1B_SUBSET.dim') java.lang.UnsatisfiedLinkError: no jhdf5 in java.library.path ... WARNING: org.esa.snap.dataio.hdf5.Hdf5ProductWriterPlugIn: class org.esa.snap.dataio.hdf5.Hdf5ProductWriterPlugIn: HDF-5 library not available: class java.lang.NoClassDefFoundError: Could not initialize class ncsa.hdf.hdf5lib.H5

The HDF5 library is available on the system:

ls /usr/lib64/ | grep libhdf5.so libhdf5.so libhdf5.so.6 libhdf5.so.6.0.4 libhdf5.so.7 libhdf5.so.7.0.3

Do you have any hint about that?

Thanks in advance
Cesare

Maybe the HDF5 libraries are not found from python.

What might work is to edit the jpyconfig.py file.
Add the options to the jvm_optionslist

-Dncsa.hdf.hdflib.HDFLibrary.hdflib=<PATH_TO_THE_HDF_LIBRARY_FILE>
-Dncsa.hdf.hdf5lib.H5.hdf5lib=<PATH_TO_THE_HDF5_LIBRARY_FILE>

Hi,

thanks for the suggestion.
We finally managed to install snappy on CentOS 6.x using the following trick:

SNAP_HOME=/opt/snap-3.0
cd $SNAP_HOME/snap/modules/lib/x86_64
ln -s ../amd64/libjhdf.so
ln -s ../amd64/libjhdf5.so

We have also packaged the snappy module as Anaconda package https://anaconda.org/terradue/snappy. It can be installed with:

conda install -c terradue snappy=3.0

It requires java-1.8.0-openjdk-devel and a SNAP installation, of course.

Cheers,
Cesare

3 posts were split to a new topic: Sen2Cor not accepting inpput product

5 posts were split to a new topic: Trouble configuring snappy