Problems with snappy and Python 3.8

Hello,

I have tried to configure snappy using Python 3.8 (conda version) in Ubuntu 20.04.4 LTS using the wheel from: https://github.com/jpy-consortium/jpy/releases/download/v0.11.0/jpy-0.11.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

I have renamed the wheel to /home/user/.snap/snap-python/snappy/jpy-0.11.0-cp38-cp38-linux_x86_64.whl and run the ./snappy-conf.

The snappy-conf generates the following message:

./snappy-conf /home/user/opt/anaconda/envs/snappy/bin/python
Configuring SNAP-Python interface...
java.io.IOException: Python configuration failed.
Command [/home/user/opt/anaconda/envs/snappy/bin/python ./snappyutil.py --snap_home /home/user/opt/snap --java_module /home/user/opt/snap/snap/modules/org-esa-snap-snap-python.jar --force --log_file ./snappyutil.log --jvm_max_mem 10G --java_home /home/user/opt/snap/jre/jre --req_arch amd64]
failed with return code 30.
Please check the log file '/home/user/.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(Thread.java:748)
Python configuration error: Python configuration failed.
Command [/home/user/opt/anaconda/envs/snappy/bin/python ./snappyutil.py --snap_home /home/user/opt/snap --java_module /home/user/opt/snap/snap/modules/org-esa-snap-snap-python.jar --force --log_file ./snappyutil.log --jvm_max_mem 10G --java_home /home/user/opt/snap/jre/jre --req_arch amd64]
failed with return code 30.

Also, I get the error below with the test below:

>>> import sys
>>> sys.path.append('/home/user/.snap/snap-python/')
>>> import snappy
RuntimeError: jpy: internal error: static method not found: unwrapProxy(Ljava/lang/Object;)Lorg/jpy/PyObject;

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/.snap/snap-python/snappy/__init__.py", line 236, in <module>
    jpy.create_jvm(options=_get_snap_jvm_options())
SystemError: <built-in function create_jvm> returned a result with an error set

Does anyone have a suggestion on what I would be doing wrong?

Thanks in advance,
Fernando

Please check my reply here:

As you found, this is not a reliable approach. Is the a reason you can’t use Python 3.6 (e.g., IT policies)?

For Ubuntu, deadsnakes PPA may have a suitable python3.6 to tide you over until SNAP gains support for current versions.
Anaconda python3.6 is also available from Anaconda.org.

Hello,

The main reason is because the Python development plugin for VS Code has dropped the support for Python 3.6 and the debugger does not work with Python 3.6 anymore.

Regards,
Fernando

I have finally found a pretty easy solution! In case someone else is affected see below my solution.

Steps:

  1. Download the file at https://anaconda.org/Terradue/jpy/0.9.0/download/linux-64/jpy-0.9.0-py38_3.tar.bz2 (Jpy 0.9.0 for Python 3.8 provided at Anaconda by Terradue at Files :: Anaconda.org)
  2. Extract the files as tar xvjf jpy-0.9.0-py38_3.tar.bz2. Now, you will have the whl in your computer.
  3. Run the command ./snappy-conf <python3.8 location> . The command will fail.
  4. Copy the whl file in the ~/.snap/snap-python/snappy/
  5. Run again the command ./snappy-conf <python3.8 location>. Everything will work.

My conclusion is that jpy 0.11.0 (at least the whl provided at Release v0.11.0 · jpy-consortium/jpy · GitHub) has some problem with snappy code or ESA Snap, since it seems that it has a problem with the object “unwrapProxy”. However, jpy 0.9.0 (compilation for Python 3.8 provided by Terradue) works without issues.

Glad you found a binary wheel that works on your system, and thank you for providing enough detail for others to follow. I tried the Teradue binary wheel on Fedora linux and it seems to work, so it may useful to others. There is some benefit to having many people using the jpy version so problems can be addressed with multiple people helping.

There have been other reports of the unwrapProxy error. Return code 30 is defined in snappyutil.py as _ERR_CODE_IMPORTING_SNAPPY_FAILED = 30.