Unable to correctly install snappy for python

I am having enormous trouble being able to use the snappy package in python. I am using Windows 10, 64-bit, anaconda3, python version 3.5.5

What I type in to test the installation is
from snappy import ProductIO
The error I get is:
ImportError: cannot import name ‘ProductIO’

Steps I’ve tried to install snappy:

  1. I’ve installed SNAP 6.0.0, used the checkbox to sync my SNAP with my python at the directory C:/Users/…/Anaconda3/python.exe

  2. I’ve followed the instructions on https://senbox.atlassian.net/wiki/spaces/SNAP/pages/50855941/Configure+Python+to+use+the+SNAP-Python+snappy+interface

  3. Instructions here https://forum.step.esa.int/t/jpy-python-java-bridge-version/329/3

  4. instructions here https://github.com/bcdev/jpy for windows install of jpy. Wheel was successfully made.

  5. the instructions here https://forum.step.esa.int/t/snappy-error-config-installation/8314/10
    for this one, I was able to follow along with all of his steps successfully, but I am unable to
    import jpy
    from my python shell in windows cmd. Everything else was exactly as his output photos show.

Below is my snappyutil.txt document:

INFO: Installing from Java module ‘C:\Program Files\snap\snap\modules\org-esa-snap-snap-python.jar’
INFO: Installing jpy…
INFO: Unzipping ‘C:\Users\Radiant Solutions.snap\snap-python\snappy\jpy-0.9.0-cp35-cp35m-win_amd64.whl’
INFO: Configuring jpy…
INFO: jpy Python API configuration written to ‘C:\Users\Radiant Solutions.snap\snap-python\snappy\jpyconfig.py’
INFO: jpy Java API configuration written to ‘C:\Users\Radiant Solutions.snap\snap-python\snappy\jpyconfig.properties’
INFO: Configuring snappy…
INFO: snappy configuration written to ‘C:\Users\Radiant Solutions.snap\snap-python\snappy\snappy.ini’
INFO: Importing snappy for final test…
INFO: Done. The SNAP-Python interface is located in ‘C:\Users\Radiant Solutions.snap\snap-python\snappy’
When using SNAP from Python, either do: sys.path.append(‘C:\Users\Radiant Solutions\.snap\snap-python\snappy’)
or copy the snappy module into your Python’s ‘site-packages’ directory.

When I run
import snappy

I get the output:
['StreamCompressor', 'StreamDecompressor', 'UncompressError', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '_snappy', 'compress', 'decompress', 'hadoop_snappy', 'hadoop_stream_compress', 'hadoop_stream_decompress', 'isValidCompressed', 'snappy', 'stream_compress', 'stream_decompress', 'uncompress']
It’s not showing ProductIO, jpy, or anything like that.

I’m at a loss for how to get this to work. If anyone knows how I can fix this and use snappy in python, that would be greatly appreciated.

I also need to get it installed and working on a jupyter notebook.

Hey, try python 3.4

Unable to correctly install snappy for python

Try things from here Unable to install snappy - jpy problem?.
I found some useful things.

1 Like

Please specify your problem

msi is the installer file. Have you installed python (or Spyder or Anaconda) correctly?

so which target directory did you chose for the installation?
python.exe is in there.

SNAP snappy supports Python 3.6 now and Python-3.6 from python.org “works for me”.

Many people use Anaconda Python and create a 3.6 environment. Python installs create a directory tree full of necessary library and scripts. On Windows I use the “network installer” and install to c:\Python36 (even on my “enterprise” Windows I can do this without “admin” privileges). Running snappy-conf.bat c:\Python36\python.exe configures snappy (on systems that have the Visual Studio redistributable files installed).

1 Like

There are multiple packages called “snappy”. The ESA SNAP version of snappy does not contain snappy_init.py, so appears you are attempting to use one of the other snappy packages.

You may have been misled because the dir(snappy) list from the original post was not from the ESA SNAP version. You should see [\\ added to make it easier to read]

>>> dir(snappy)
['AbstractBand', 'ArrayList', 'Arrays', 'Band', 'Collections', 'ConvolutionFilterBand', \\
'CrsGeoCoding', 'DefaultGeographicCRS', 'EXCLUDED_DIR_NAMES', \\
'EXCLUDED_JAR_NAMES', 'EXCLUDED_NB_CLUSTERS', 'Engine', 'EngineConfig', \\
'FeatureUtils', 'File', 'FlagCoding', 'GPF', 'GeneralFilterBand', 'GeoCoding', 'GeoPos', \\
'Geometry', 'HashMap', 'HashSet', 'List', 'ListFeatureCollection', 'Map', 'Mask', \\
'Operator', 'PixelGeoCoding', 'PixelGeoCoding2', 'PixelPos', 'PlainFeatureFactory', \\
'Point', 'Product', 'ProductData', 'ProductIO', 'ProductNodeGroup', 'ProductUtils', \\
'ProgressMonitor', 'RasterDataNode', 'Rectangle', 'Set', 'SimpleFeatureBuilder', 'String', \\
'SystemUtils', 'TiePointGeoCoding', 'TiePointGrid', 'Tile', 'VectorDataNode', \\
'VirtualBand', 'WKTReader', '__builtins__', '__cached__', '__doc__', '__file__', \\
'__loader__', '__name__', '__package__', '__path__', '__spec__', \\
'_get_nb_user_modules_dir', 'annotate_RasterDataNode_methods', 'called_from_java', \\
'config', 'cp', 'debug', 'glob', 'jpy', 'jpyutil', 'module_dir', 'module_ini', 'os', 'snap_home', \\
'start_snap_engine', 'sys']

To use Anaconda3 with the supplied jpy wheels you need to create a Python 3.6 environment. If you follow these instructions using a Python 3.6 environment you should get a properly configured ESA STEP snappy. Since you appear to have other snappy Python packages, you should avoid installing snappy into your Python system, but instead use either the PYTHONPATH mechanism or add the sys.path entry to your python scripts.