Anaconda snappy error

I attached every package for snappy and make all changes in it to run in windows anaconda properly and after 30+ times of error everything looking good. but when I tried to import snappy an error comes to me which I can’t fix. Please help me.
import snappy
Traceback (most recent call last):

File “”, line 1, in
import snappy

File “C:\Users\subha\anaconda3\lib\site-packages\snappy_init_.py”, line 236, in
jpy.create_jvm(options=_get_snap_jvm_options())

File “C:\Users\subha\anaconda3\lib\site-packages\snappy_init_.py”, line 210, in _get_snap_jvm_options
class_path += extra_class_path.split(os.pathsep)

TypeError: unsupported operand type(s) for +=: ‘dict_values’ and ‘list’

I think here is the problem in the setup files.

    env = _get_snap_jvm_env()
class_path = env[0].values()
library_path = env[1]

if config.has_option('DEFAULT', 'java_class_path'):
    extra_class_path = config.get('DEFAULT', 'java_class_path')
    class_path += extra_class_path.split(os.pathsep)

if config.has_option('DEFAULT', 'java_library_path'):
    extra_library_path = config.get('DEFAULT', 'java_library_path')
    library_path += extra_library_path.split(os.pathsep)

how to fix this error can anyone help me. I am not a expert in program developer please help me to solve this.

1 Like

There are many Python packages called “snappy”: Python package for Google’s compression library, Python package for study of 3-D manifolds, Python network analysis . This forum is for ESA SNAP, a Java GUI for remote sensing which provides yet another snappy Python package. If you are using ESA SNAP, you may have inadvertently installed some other package called “snappy”.

This sounds like a Python2/Python3 conflict.
At least, when I follow this Stackoverflow thread:

That’s strange because many people use snappy already with Python3.
But the code is only used if certain options are set in the snappy.ini file.
Have you created a snappy.ini?

To fix the problem it might work to turn the dict into a list. Modify the __init__.py as follows

env = _get_snap_jvm_env()
class_path = list(env[0].values())  # turned into list
library_path = list(env[1]) # turned into list

if config.has_option('DEFAULT', 'java_class_path'):
    extra_class_path = config.get('DEFAULT', 'java_class_path')
    class_path += extra_class_path.split(os.pathsep)

if config.has_option('DEFAULT', 'java_library_path'):
    extra_library_path = config.get('DEFAULT', 'java_library_path')
    library_path += extra_library_path.split(os.pathsep)

Yes, I already build the snappy.ini also converted those into list but still now getting error.
import snappy
from snappy import ProductIO
import jpy
img=ProductIO.readProduct(r’C:\Users\subha.snap\snap-python\snappy\testdata\MER_FRS_L1B_SUBSET.dim’)
Traceback (most recent call last):

File “”, line 4, in
img=ProductIO.readProduct(r’C:\Users\subha.snap\snap-python\snappy\testdata\MER_FRS_L1B_SUBSET.dim’)

RuntimeError: java.lang.IllegalArgumentException: org.geotools.styling.StyleFactory is not an ImageIO SPI class

I am using this, with
Java 8
python 3.6
jpy 0.9.0
snap latest

I am using jdk to build. can I use jre in the snap directory?
or how to fix this error?

Yes, I already build the snappy.ini also converted those into list but still now getting error.

https://forum.step.esa.int/t/org-geotools-styling-stylefactory-is-not-an-imageio-spi-class/13732/6?u=subhaoo7

I am using jdk to build. can I use jre in the snap directory?
or how to fix this error?

To let your script run it would be good to use the jre provided by SNAP.
The JDK is not necessary.
As I can’t reproduce the error I can’t help much further. Sorry.

No problem, can you please help me just for jpy installation in windows without build it or something. I tried to install it from pip but get an error

Environment variable “JDK_HOME” must be set to a JDK (>= v1.6) installation directory

I can’t understand why?

More detail would help us to understand your problem. What Windows version (e.g., 64-bit Windows 10)? Did you follow the steps in Configure Python to use Snappy?

Windows systems often have multiple python.exe programs (32-bit, 64-bit, python 2.7, python 3.6, etc). Many 3rd party programs install their own python.exe (QGIS, ArcGIS, etc.). What do you get for python --version in the terminal where you want to use snappy?

You should be able to use the JRE provided by SNAP unless you need to build your own jpy, which does require a JDK and other build tools.

Are you using an anaconda environment to select python 3.6? Did you run snappy-conf.py? Can you show us the resulting %USERPROFILE%\.snap\snap-python\snappy\snappyutil.log?
Assuming you have 64-bit SNAP and 64-bit python 3.6, you should have a line like:

INFO: Extracting 'lib/jpy-0.9.0-cp36-cp36m-win_amd64.whl' from '<some_path>\SNAP\modules\org-esa-snap-snap-python.jar'

I am using windows 64 bit OS. After some errors I found the problem and uninstall everything (i.e. SNAP, jpy, JDK) then I fress install the SNAP without python config, JDK with the same version used by SNAP and maven 3.6.3, VS was already installed.
After re-build jpy wheel, I config snap with python 3.7 (anaconda) within the site-packages. now jpy is working fine and snappy is importing in python on second try,
see the error:

import snappy
Traceback (most recent call last):

  File "<ipython-input-1-710a7f18823c>", line 1, in <module>
import snappy

  File "C:\Users\subha\anaconda3\lib\site-packages\snappy\__init__.py", line 381, in <module>
Engine.start()

RuntimeError: java.lang.UnsatisfiedLinkError: org.gdal.gdalconst.gdalconstJNI.GDT_Unknown_get()I


import snappy
from snappy import ProductIO
 p=ProductIO.readProduct(r'C:\Users\subha\anaconda3\Lib\site-packages\snappy\testdata\MER_FRS_L1B_SUBSET.dim')

p
Out[11]: org.esa.snap.core.datamodel.Product(objectRef=0x000002593F74EBC8)

list(p.getBandNames())
Out[14]: 
['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']

Don’t know why it shows error in first import. If anyone have idea on this error please teach me.

I also need a manual for sentinel data processing with it, anyone please help me.

I sometimes see a “SEVERE” message related to GDAL, but not today. Have you updated SNAP?

PS C:\Users\gwhite\.snap\snap-python> C:\Python36\python
Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from snappy import ProductIO
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.
>>> p = ProductIO.readProduct('snappy/testdata/MER_FRS_L1B_SUBSET.dim')
INFO: org.hsqldb.persist.Logger: dataFileCache open start
>>> list(p.getBandNames())
['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']

Note that it is redundant to import snappy and then from snappy import ....

The WIKI has introductory material on SNAP and snappy.

I don’t update SNAP yet. is it ok to update SNAP?

When you start the SNAP GUI it should tell you if updates are available. Usually the updates fix bugs, and before reporting problems it is best to update so you aren’t wasting time on a bug that has been fixed. It is possible that the GDAL message has been fixed by an update.

Ok, I found the solution of java gdal error. before import snappy in python, import gdal. most of your gdal error will be solved. or add import gdal command in init.py file of snappy directory.