Python configuration error while configuring snappy

Dear all,
I’ve been trying to use snap with python 3.9.12 in Jupyter notebook. Tried using python 3.4 and all excercise went in vain. After a week’s futile exercise. Now again installed python 3.9.12 and while trying this, the error is like this in SNAP command line:
snappy-conf C:\Users\HP\anaconda3\envs\snap\python.exe C:\Users\HP\anaconda3\envs\snap\Lib\site-packages

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.
OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=384m; support was removed in 8.0
Python configuration internal error: org/esa/snap/core/util/Debug

Please suggest, why there is a confusion while installing snap and configuring snappy? Although, I installed snap this time in the same environment, I created in anaconda.

SNAP bundles jpy for older python versions, so you need to provide a jpy binary wheel that matches your python version. Please see: Out-of-the-box support on Python 3.7 or above for snappy after Python 3.6 End of Life (on Dec 21) - #7 by Ferni.

I have run into similar problems, and although I have successfully integrated snappy with Python 3.9, I had trouble repeating it when the environment got more complicated. I suggest you use Anaconda to install python 3.6 in the environment and run it from there. This will simplify a lot of things for you.

If you really need Python 3.9, consider using the python library “subprocess” to run a separate python script in 3.6, just for the snappy processing.

After uninstalling everything and installing Python3.6 this is the message I’m getting:

snappy-conf C:\Users\HP\Anaconda3\python.exe C:\Users\HP.snap\snap-python

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.
OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=384m; support was removed in 8.0
Python configuration error: Python configuration failed.
Command [C:\Users\HP\Anaconda3\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\jre” --req_arch amd64]
failed with return code 1.
Please check the log file ‘C:\Users\HP.snap\snap-python\snappy\snappyutil.log’.

Now 8 days are gone doing exclusively this exercise. I’ll really appreciate if some friend configure snappy for me through screen sharing mode. And I need to use the configuration in Google Colab.

See what the log file says at the file path. It will be helpful.

Could you also show us your windows environment variables? I suspect jpy isn’t finding something, but I’m not sure.

Thanks for responding cndnflyr,

Snappy util.log file says:
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.9.0-cp36-cp36m-win_amd64.whl’ from ‘C:\Program Files\snap\snap\modules\org-esa-snap-snap-python.jar’
INFO: Unzipping ‘C:\Users\HP.snap\snap-python\snappy\lib\jpy-0.9.0-cp36-cp36m-win_amd64.whl’
INFO: Configuring jpy…
INFO: jpy Python API configuration written to ‘C:\Users\HP.snap\snap-python\snappy\jpyconfig.py’
INFO: jpy Java API configuration written to ‘C:\Users\HP.snap\snap-python\snappy\jpyconfig.properties’
INFO: Configuring snappy…
INFO: snappy configuration written to ‘C:\Users\HP.snap\snap-python\snappy\snappy.ini’
INFO: Importing snappy for final test…
Perhaps the dependency file for jvm.dll. But I don’t know about it.

Windows environment variables:

You appear to be using Anaconda Python. Anaconda adds environment variables to it is necessary to use an Anaconda terminal to run Anaconda python.

You can redo the “final test” using python on the command-line (see Configure Python to use the SNAP-Python snappy interface).

This shows none of the variables set by an Anaconda environment.

Tried once again after unistalling anaconda and reinstalling python 3.6.8. And got the message below:
[C:\Python\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\jre” --req_arch amd64]
failed with return code 30.

How did you install python 3.6.8? Pleas show us snappyutil.log – it should tells the reason for
“return code 30”.

I installed python3.6.8 through python installer in Drive C.
snappyutil.log file says as below:
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.9.0-cp36-cp36m-win_amd64.whl’ from ‘C:\Program Files\snap\snap\modules\org-esa-snap-snap-python.jar’
INFO: Unzipping ‘C:\Python\Python36\Lib\site-packages\snappy\lib\jpy-0.9.0-cp36-cp36m-win_amd64.whl’
INFO: Configuring jpy…
INFO: jpy Python API configuration written to ‘C:\Python\Python36\Lib\site-packages\snappy\jpyconfig.py’
INFO: jpy Java API configuration written to ‘C:\Python\Python36\Lib\site-packages\snappy\jpyconfig.properties’
INFO: Configuring snappy…
INFO: snappy configuration written to ‘C:\Python\Python36\Lib\site-packages\snappy\snappy.ini’
INFO: Importing snappy for final test…
ERROR: Configuration failed with exit code 30

Error 30 can occur when you have a jpy version that targets recent Java versions, see Problems with snappy and Python 3.8.

The “final test” that failed attempts to load [ESA]snappy. In a terminal, run your python3.6 and try import snap. This should give details of the error.

Hello everyone,
I have spent several days to be able to install snappy. So, I thought it would be useful to write down the procedure that I followed. I tried to create a new topic in the forum entitled “Snappy Installation in Ubuntu” , but I couldn’t - probably because of my membership limitations. If the forum admins could move this post to a new topic or let me know how to do it, it would be great. Also, any suggestions/edits would be appreciated.

To install snappy in ubuntu 22.04, Anaconda 3 for python 3.9 I did the following steps:

• If you don’t have python installed, the first step is to install python – as mentioned above, I had installed Anaconda 3 – python3.9.
• Next, make sure you have java installed as well. It is recommended to install JDK 8 with oracle distribution. you can search the instructions and where you can find the archived versions.
Please note that even if you have openjdk installed, you may still have to install JDK 8 with oracle distribution and prioritize it.
• Then, run the sudo vim ~/.profile or sudo vim ~/.bashrc (depending on your system), and edit the path for JDK_HOME and JAVA_HOME as follows- you could do this step after snap installation:
export JDK_HOME=/usr/lib/jvm/jdk1.8.0_333 #this is an example path
export JAVA_HOME=$JDK_HOME
• Then, install maven for ubuntu.
• Next, you need to install snap. For doing so, download the unix .sh file for the current snap version, cd to where you downloaded the file, and run:
sudo chmod +x esa-snap_sentinel_unix_5_0.sh
./esa-snap_sentinel_unix_5_0.sh
• Then, run the following commands (documentation can be found in github under jpy-consortium):
git clone “jpy-consortium https link”
cd jpy
python setup.py build maven bdist_wheel
cp dist/*.whl “/root/.snap/snap-python/snappy”
If you encountered the error: Error: environment variable “JAVA_HOME” must be set to a JDK (>= v1.7) installation directory It means that you have not set the JDK_HOME and JAVA_HOME, or have not done this correctly. Note that the Java home should include “include” and “lib” directories.
• Afterwards, you should configure python for snappy:
cd “snap installation directory”/bin
./snappy-conf “python executable”
If the configuration fails with code 10, it means that you have not configured jpy correctly, or you have not copied the wheel to the snappy directory.
If the configuration fails with code 30, the version of the copied wheel is not compatible with the python version. In this case, you could find ideas how to fix it by searching in this forum . In shorts, you have to download another wheel which is compatible with your python version, and copy it to the snappy folder.
• The final step is to open python and run the following commands to check if snappy is up and running:
import sys
sys.path.append(’/home/sahel/.snap/snap-python/snappy/’)
from snappy import ProductIO
if you encountered error, make sure you have specified the installation directory correctly, and make sure conda has not confused snappy with another package with the same name.
if these lines run smoothly, you are good to go!

4 Likes

thank you for sharing

1 Like

Using sys.path.append puts the ESA SNAP snappy directory at the tail end of the python path. If you have installed another package called snappy you should use `sys.path.insert(1,<ESA_SNAP_snappy_dir>)’ (this leaves the first entry as the directory where you ran the python command).

Note that other tools may stop working with JDK_HOME or JAVA_HOME set to Java 8. In such cases, “environment module” can be used to adjust environment settings from the command-line.

1 Like