Using snappy

I am trying to use snappy in SNAP using SNAP command-line. like this :

Welcome to the SNAP command-line interface.
The following command-line tools are available:
gpt - Graph Processing Tool
pconvert - Data product conversion and quicklook generation
snap64 - SNAP Desktop launcher
snappy-conf - Configuration tool for the SNAP-Python interface
Typing the name of each tool will output its usage information

I try using python36 and python27 in SNAP 6.0 it is problem. Below shown the python36:

snappy-conf C:\Python36\python.exe

The launcher has determined that the parent process has a console and will reuse it for its own console output.
Closing the console will result in termination of the running program.
Use ‘–console suppress’ to suppress console output.
Use ‘–console new’ to create a separate console window.
Configuring SNAP-Python interface…
java.io.IOException: Python configuration failed.
Command [C:\Python36\python.exe .\snappyutil.py --snap_home “C:\Program Files\snap” --java_module “C:\Program Files\snap\snap\modules\org-esa-snap-snap-python.jar” --force --log_file .\snappyutil.log --jvm_max_mem 5G --java_home “C:\Program Files\snap\jre” --req_arch amd64]
failed with return code 10.
Please check the log file ‘C:\Users\Iqbal.snap\snap-python\snappy\snappyutil.log’.
at org.esa.snap.python.PyBridge.configureJpy(PyBridge.java:232)
at org.esa.snap.python.PyBridge.installPythonModule(PyBridge.java:149)
at org.esa.snap.rcp.cli.SnapArgsProcessor.processPython(SnapArgsProcessor.java:103)
at org.esa.snap.rcp.cli.SnapArgsProcessor.process(SnapArgsProcessor.java:49)
at org.netbeans.modules.sendopts.DefaultProcessor.process(DefaultProcessor.java:202)
at org.netbeans.spi.sendopts.Option$1.process(Option.java:387)
at org.netbeans.api.sendopts.CommandLine.process(CommandLine.java:317)
at org.netbeans.modules.sendopts.HandlerImpl.execute(HandlerImpl.java:62)
at org.netbeans.modules.sendopts.Handler.cli(Handler.java:69)
at org.netbeans.CLIHandler.notifyHandlers(CLIHandler.java:234)
at org.netbeans.core.startup.CLICoreBridge.cli(CLICoreBridge.java:82)
at org.netbeans.CLIHandler.notifyHandlers(CLIHandler.java:234)
at org.netbeans.CLIHandler$1.exec(CLIHandler.java:268)
at org.netbeans.CLIHandler.finishInitialization(CLIHandler.java:447)
at org.netbeans.MainImpl.finishInitialization(MainImpl.java:256)
at org.netbeans.Main.finishInitialization(Main.java:92)
at org.netbeans.core.startup.Main.start(Main.java:316)
at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:123)
at java.lang.Thread.run(Unknown Source)
Python configuration error: Python configuration failed.
Command [C:\Python36\python.exe .\snappyutil.py --snap_home “C:\Program Files\snap” --java_module “C:\Program Files\snap\snap\modules\org-esa-snap-snap-python.jar” --force --log_file .\snappyutil.log --jvm_max_mem 5G --java_home “C:\Program Files\snap\jre” --req_arch amd64]
failed with return code 10.
Please check the log file ‘C:\Users\Iqbal.snap\snap-python\snappy\snappyutil.log’.

and Python27:

snappy-conf C:\Python2714\python.exe

The launcher has determined that the parent process has a console and will reuse it for its own console output.
Closing the console will result in termination of the running program.
Use ‘–console suppress’ to suppress console output.
Use ‘–console new’ to create a separate console window.
Configuring SNAP-Python interface…
java.io.IOException: Python configuration failed.
Command [C:\Python2714\python.exe .\snappyutil.py --snap_home “C:\Program Files\snap” --java_module “C:\Program Files\snap\snap\modules\org-esa-snap-snap-python.jar” --force --log_file .\snappyutil.log --jvm_max_mem 5G --java_home “C:\Program Files\snap\jre” --req_arch amd64]
failed with return code 30.
Please check the log file ‘C:\Users\Iqbal.snap\snap-python\snappy\snappyutil.log’.
at org.esa.snap.python.PyBridge.configureJpy(PyBridge.java:232)
at org.esa.snap.python.PyBridge.installPythonModule(PyBridge.java:149)
at org.esa.snap.rcp.cli.SnapArgsProcessor.processPython(SnapArgsProcessor.java:103)
at org.esa.snap.rcp.cli.SnapArgsProcessor.process(SnapArgsProcessor.java:49)
at org.netbeans.modules.sendopts.DefaultProcessor.process(DefaultProcessor.java:202)
at org.netbeans.spi.sendopts.Option$1.process(Option.java:387)
at org.netbeans.api.sendopts.CommandLine.process(CommandLine.java:317)
at org.netbeans.modules.sendopts.HandlerImpl.execute(HandlerImpl.java:62)
at org.netbeans.modules.sendopts.Handler.cli(Handler.java:69)
at org.netbeans.CLIHandler.notifyHandlers(CLIHandler.java:234)
at org.netbeans.core.startup.CLICoreBridge.cli(CLICoreBridge.java:82)
at org.netbeans.CLIHandler.notifyHandlers(CLIHandler.java:234)
at org.netbeans.CLIHandler$1.exec(CLIHandler.java:268)
at org.netbeans.CLIHandler.finishInitialization(CLIHandler.java:447)
at org.netbeans.MainImpl.finishInitialization(MainImpl.java:256)
at org.netbeans.Main.finishInitialization(Main.java:92)
at org.netbeans.core.startup.Main.start(Main.java:316)
at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:123)
at java.lang.Thread.run(Unknown Source)
Python configuration error: Python configuration failed.
Command [C:\Python2714\python.exe .\snappyutil.py --snap_home “C:\Program Files\snap” --java_module “C:\Program Files\snap\snap\modules\org-esa-snap-snap-python.jar” --force --log_file .\snappyutil.log --jvm_max_mem 5G --java_home “C:\Program Files\snap\jre” --req_arch amd64]
failed with return code 30.
Please check the log file ‘C:\Users\Iqbal.snap\snap-python\snappy\snappyutil.log’.

The snappyutil.log looks like :

INFO: Installing from Java module ‘C:\Program Files\snap\snap\modules\org-esa-snap-snap-python.jar’
INFO: Installing jpy…
ERROR: The module ‘jpy’ is required to run snappy, but no binary ‘jpy’ wheel matching the pattern
ERROR: ‘jpy-{version}-cp36-{abi_tag}-win32.whl’ could be found.
You can try to build a ‘jpy’ wheel yourself and then copy it into
“C:\Users\Iqbal.snap\snap-python\snappy” and then run the configuration again.
Please go to https://github.com/bcdev/jpy and follow the build instructions. E.g.

git clone https://github.com/bcdev/jpy.git
cd jpy
python setup.py bdist_wheel
cp dist/*.whl “C:\Users\Iqbal.snap\snap-python\snappy”
ERROR: Configuration failed

After that try this step and download jdk-9.0.4 and follow the step :

git clone https://github.com/bcdev/jpy.git
cd jpy
python setup.py bdist_wheel

the error like this:
C:\Python2714\jpy>python setup.py build
Note that you can use non-standard global option [–maven] to force a Java Maven build for the jpy Java API
Error: Cannot find any JVM shared library

C:\Python2714\jpy>python setup.py --maven build
Error: Cannot find any JVM shared library

Any solution for this. Thank you

I think snap is meant to provide the binary jpy wheel for at least Python 2.7 on common platforms. In your snappyutil.log it looks like snappy-config thinks your C:\Python2714\python.exe is version 3.6, so you should check the version of your C:\Python2714\python.exe.

On Windows you need Microsoft Visual Studio (see README.rst). The winbuild.cmd file in the jpy directory will handle the settings mentioned in README.rst. If you have one of the Visual Studio versions, you could try running winbuild.cmd.

Thank gnwii. Before I install python27 under directory arcgis then i try to install in different directory of C:\Python\python.exe but the error :

INFO: Installing from Java module ‘C:\Program Files\snap\snap\modules\org-esa-snap-snap-python.jar’
INFO: Installing jpy…
INFO: Extracting ‘lib/jpy-0.8.0-cp27-none-win32.whl’ from ‘C:\Program Files\snap\snap\modules\org-esa-snap-snap-python.jar’
INFO: Unzipping ‘C:\Users\USER.snap\snap-python\snappy\lib\jpy-0.8.0-cp27-none-win32.whl’
INFO: Configuring jpy…
INFO: jpy Python API configuration written to ‘C:\Users\USER.snap\snap-python\snappy\jpyconfig.py’
INFO: jpy Java API configuration written to ‘C:\Users\USER.snap\snap-python\snappy\jpyconfig.properties’
INFO: Configuring snappy…
INFO: snappy configuration written to ‘C:\Users\USER.snap\snap-python\snappy\snappy.ini’
INFO: Importing snappy for final test…
ERROR: Configuration failed
Traceback (most recent call last):
File “.\snappyutil.py”, line 266, in main
force=args.force)
File “.\snappyutil.py”, line 213, in configure_snappy
import(‘snappy’)
File "C:\Users\USER.snap\snap-python\snappy…\snappy_init
.py", line 63, in
jpyutil.preload_jvm_dll()
File “C:\Users\USER.snap\snap-python\snappy…\snappy\jpyutil.py”, line 315, in preload_jvm_dll
return ctypes.CDLL(jvm_dll_file, mode=ctypes.RTLD_GLOBAL)
File "C:\Python\lib\ctypes_init
.py", line 366, in init
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 193] %1 is not a valid Win32 application

Hope can help.And I also remove python36 before install the python27 in the new directory.

The snappy configuration chose jpy-0.8.0-cp27-none-win32.whl, a 32-bit jpy. This requires that SNAP and Python both be 32-bit applications. The last message WindowsError: [Error 193] %1 is not a valid Win32 application suggests that you have mixed 32-bit and 64-bit applications. What does the JVM line in the “About SNAP” panel say? For 64-bit SNAP and Python, snappyutil.log should have jpy-0.8.0-cp27-none-win_amd64.whl.

Ok I will try first. Maybe I install the wrong python for 32bit. Thanks.

I decide to remove the previous python36 to python34 but there is problem. when i looked out at snappyutil.log like this :

INFO: Installing from Java module ‘C:\Program Files\snap\snap\modules\org-esa-snap-snap-python.jar’
INFO: Installing jpy…
INFO: Extracting ‘lib/jpy-0.8.0-cp34-none-win32.whl’ from ‘C:\Program Files\snap\snap\modules\org-esa-snap-snap-python.jar’
INFO: Unzipping ‘C:\Users\Iqbal.snap\snap-python\snappy\lib\jpy-0.8.0-cp34-none-win32.whl’
INFO: Configuring jpy…
INFO: jpy Python API configuration written to ‘C:\Users\Iqbal.snap\snap-python\snappy\jpyconfig.py’
INFO: jpy Java API configuration written to ‘C:\Users\Iqbal.snap\snap-python\snappy\jpyconfig.properties’
INFO: Configuring snappy…
INFO: snappy configuration written to ‘C:\Users\Iqbal.snap\snap-python\snappy\snappy.ini’
INFO: Importing snappy for final test…
ERROR: Configuration failed
Traceback (most recent call last):
File “.\snappyutil.py”, line 266, in main
force=args.force)
File “.\snappyutil.py”, line 213, in configure_snappy
import(‘snappy’)
File "C:\Users\Iqbal.snap\snap-python\snappy…\snappy_init
.py", line 63, in
jpyutil.preload_jvm_dll()
File “C:\Users\Iqbal.snap\snap-python\snappy\jpyutil.py”, line 315, in preload_jvm_dll
return ctypes.CDLL(jvm_dll_file, mode=ctypes.RTLD_GLOBAL)
File "C:\Python34\lib\ctypes_init
.py", line 351, in init
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application

error in snappy.ini for importing snappy.

my snappy.ini like this :

[DEFAULT]
snap_home = C:\Program Files\snap
java_max_mem: 5G

snap_start_engine: False

java_class_path: ./target/classes

java_library_path: ./lib

java_options: -Djava.awt.headless=false

debug: False

Any suggestion for the configuration. Thanks

Once again, it looks like you are mixing 32-bit with 64-bit software. Unfortunately, you don’t provide details. These are important both so we can solve your problem and to help others with similar problems determine if they have the same configuration that failed for you. Did you install Win32 or Win64 SNAP? Which python distribution did you install? Do you have more than one Python installed?

1 Like

I got it manage it now. In python34 I found some module, they have some error. So I remove and replace them. So now it works using the snappy-conf. Can you give me some handouts for using snappy-conf to process sentinel-1 and 2? Thanks