Configure Python to use the SNAP-Python (snappy) interface

The easiest way to configure your Python installation for the usage SNAP-Python (snappy) interface is to do it during the installation of SNAP. Within the installer you can simply activate a checkbox and select the path to the python executable.

But it is also not a big deal to do it later manually if you might have forgotten it or if you want to configure an other Python installation for snappy. Open the command line at the bin folder of the SNAP installation directory. On Windows you can simply choose 'SNAP Command-Line' from the Start menu.
Now type

$ cd <snap-install-dir>/bin

$ ./snappy-conf <python-exe>


$ snappy-conf <python-exe>

This will generate the Python module snappy configured for the current SNAP installation and your Python interpreter <python-exe> into the .snap/snap-python
directory of the user home directory. The parameter <python-exe> must be the full path to the Python interpreter executable which you want to use with SNAP (supported versions are 2.7, 3.3 to 3.6).  If you want the snappy module to be placed somewhere else use:

$ ./snappy-conf <python-exe> <snappy-dir>


$ snappy-conf <python-exe> <snappy-dir>

Next you can call the tool with the path to the python executable and optionally you can specify a directory where the snappy folder should be created.

When seeing result below the configuration was successful.

To test snappy,

$ cd <snappy-dir>
(start your Python interpreter)

Then try the following code:

This approach only works if the current working directory is in the <snappy-dir>. To generally make use of snappy you need to do one of the following configuration steps.

Configure Python

To effectively use the SNAP Python API from Python, the snappy module must be detectable by your Python interpreter. There are a number of ways to achieve this. 

  • To make snappy permanently accessible, you could install it into your Python installation. On the command line (shell, terminal window on Unixes, cmd on Windows), type

$ cd <snappy-dir>/snappy
$ <python-exe> install
This might require root privileges on Unix systems and results in a snappy folder in usr/local/lib/python/dist-packages/

  • If you encounter any problems with this approach, you can also try to copy the <snappy-dir>/snappy directory directly into the site-packages directory of your Python installation.
  • Or you could also temporarily or permanently set your PYTHONPATH environment variable:

export PYTHONPATH=$PYTHONPATH:<snappy-dir>   (on Unix OS)
set PYTHONPATH=%PYTHONPATH%;<snappy-dir>
    (on Windows OS)

  • Finally, you could also append <snappy-dir> to the sys.path variable in your Python code before importing snappy:
  • In case you seek for a generic solution without needing to set <snappy-dir> you may automatically find snappy through the 'USERPROFILE' environment variable. Note that this solution requires snappy to be located at the value of 'USERPROFILE':

Change the Memory Settings

Within <snappy-dir> a file named snappy.ini is located. here you can change how much memory snappy can use.

Change the line from

# java_max_mem: 4G

to e.g.

java_max_mem: 6G

This means that snappy can use 6GB of your RAM. A recommended value is 70%-80% of the available RAM in your system.