snappy install on Linux

Dear SNAP community

I am facing an issue while installing jpy used to run snappy toolbox. here are the log. do you have any idea?

16:12:28 $ export JDK_HOME=/usr/lib/jvm/java-8-openjdk-amd64/
16:13:01 $ export PATH=$JDK_HOME/bin:$PATH
16:13:12 $ pip install jpy
Collecting jpy
  Using cached jpy-0.7.5.zip (144 kB)
    ERROR: Command errored out with exit status 1:
     command: /home/clamart/.conda/envs/yield/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-gj7c24n1/jpy/setup.py'"'"'; __file__='"'"'/tmp/pip-install-gj7c24n1/jpy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-40txd3hg
         cwd: /tmp/pip-install-gj7c24n1/jpy/
    Complete output (6 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-gj7c24n1/jpy/setup.py", line 100, in <module>
        with open('README.rst') as file:
    FileNotFoundError: [Errno 2] No such file or directory: 'README.rst'
    Building a 64-bit library for a Linux system
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Thanks

Martin

The current jpy is version 0.9.0. Using the normal Python installation tools for ESA SNAP snappy has been problematic due to outdated versions and multiple packages with the same name.

ESA SNAP snappy is widely used with Python 2.7 and 3.6 and the supplied binary wheels for jpy. I recommend sticking with Python 3.6 as the most current widely used version for snappy.

If your linux distribution does not provide Python 3.6 you can install Anaconda3 Python and add a Python 3.6 environment, or you can install Python3.6 from source and use it exclusively for snappy. For the latter method I Python 3.6 in /opt/python.org/Python36 and then use a “shebang” in python scripts:

 % cat ./snappy-check.py
#! /opt/python.org/Python36/bin/python3.6
# 
# test ESA SNAP 8.0 snappy installation

import sys
import os
# windows:
# snappy_envar = 'USERPROFILE'
# linux:
snappy_envar = 'HOME'
envs = os.environ
if not snappy_envar in envs.keys():
    raise Exception('Snappy not found')
else:
    snappy_dir = os.path.join(envs.get(snappy_envar), '.snap', 'snap-python')
sys.path.append(snappy_dir)
from snappy import ProductIO
test_file = os.path.join(snappy_dir, 'snappy/testdata/MER_FRS_L1B_SUBSET.dim')
p = ProductIO.readProduct(test_file)
print(list(p.getBandNames()))

This script just lists the band names in the snappy testdata file:

 % ./snappy-check.py
INFO: org.esa.s2tbx.dataio.gdal.GDALVersion: GDAL 3.0.4 found on system. JNI driver will be used.
INFO: org.esa.s2tbx.dataio.gdal.GDALVersion: Installed GDAL 3.0.4 set to be used by SNAP.
INFO: org.esa.snap.core.gpf.operators.tooladapter.ToolAdapterIO: Initializing external tool adapters
INFO: org.esa.snap.core.util.EngineVersionCheckActivator: Please check regularly for new updates for the best SNAP experience.
INFO: org.esa.s2tbx.dataio.gdal.GDALVersion: Installed GDAL 3.0.4 set to be used by SNAP.
INFO: org.hsqldb.persist.Logger: dataFileCache open start
['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']

Thanks @gnwii fro your reply.

So I installed a virtual env based on python 3.6:

conda create -m -p /path/to/env/snappy python=3.6 gdal numpy 

then I activate it:

conda activate /path/to/env/snappy

Then I run the same command lines as shown on my first post

export JDK_HOME=/usr/lib/jvm/java-8-openjdk-amd64/
export PATH=$JDK_HOME/bin:$PATH
pip install jpy

and I got the same error

Collecting jpy
  Using cached jpy-0.7.5.zip (144 kB)
    ERROR: Command errored out with exit status 1:
     command: /eos/jeodpp/home/users/clamart/snappy/bin/python3.6 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-hz3rq19z/jpy/setup.py'"'"'; __file__='"'"'/tmp/pip-install-hz3rq19z/jpy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-ch0icucl
         cwd: /tmp/pip-install-hz3rq19z/jpy/
    Complete output (6 lines):
    Building a 64-bit library for a Linux system
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-hz3rq19z/jpy/setup.py", line 100, in <module>
        with open('README.rst') as file:
    FileNotFoundError: [Errno 2] No such file or directory: 'README.rst'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

I obtained the same error.

I checked python version and it seems correct to me:
Python 3.6.11 | packaged by conda-forge | (default, Aug 5 2020, 20:09:42)

What do I do wrong ?

Thanks

Do not use pip install jpy for ESA SNAP snappy – as you can see it finds jpy version 0.7.5. Do use Configure Python to the SNAP Python snappy interface to get the current jpy version provided by SNAP and to avoid installed one of the other Python packages called “snappy”. You will not need a JDK to build jpy because SNAP provides a binary wheel for Python 3.6 on 64-bit linux.

1 Like