Fail python configuration on ubuntu and python 3.8

Hello

I install ESA-SNAP 8.0 64bit on Ubuntu 20.04 64 bit and i have python3.8 version 64 bit and Java-1.11.0-openjdk-amd64 .

I have problem with python configuration to take snappy python API .

In config step i take this error :
./snappy-conf /usr/bin/python3 /home/username/.snap/snap-python/snappy

Configuring SNAP-Python interface…
java.io.IOException: Python configuration failed.
Command [/usr/bin/python3 ./snappyutil.py --snap_home /home/username/snap --java_module /home/username/snap/snap/modules/org-esa-snap-snap-python.jar --force --log_file ./snappyutil.log --jvm_max_mem 5G --java_home /home/username/snap/jre/jre --req_arch amd64]
failed with return code 10.
Please check the log file ‘/home/username/.snap/snap-python/snappy/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 [/usr/bin/python3 ./snappyutil.py --snap_home /home/username/snap --java_module /home/username/snap/snap/modules/org-esa-snap-snap-python.jar --force --log_file ./snappyutil.log --jvm_max_mem 5G --java_home /home/username/snap/jre/jre --req_arch amd64]
failed with return code 10.
Please check the log file ‘/home/username/.snap/snap-python/snappy/snappy/snappyutil.log’.

In snappyutil.log :

INFO: Installing from Java module ‘/home/username/snap/snap/modules/org-esa-snap-snap-python.jar’
WARNING: Architecture requirement possibly not met: Python is x86_64 but JVM requires amd64
INFO: Installing jpy…
ERROR: The module ‘jpy’ is required to run snappy, but no binary ‘jpy’ wheel matching the pattern
‘jpy-{version}-cp38-{abi_tag}-linux_x86_64.whl’ could be found.
You can try to build a ‘jpy’ wheel yourself, then copy it into
“/home/saran/.snap/snap-python/snappy”, and then run the configuration again.
Unzip the jpy sources in /home/username/.snap/snap-python/snappy/jpy-.zip, then
cd jpy-<version> python setup.py bdist_wheel
cp dist/*.whl "/home/username/.snap/snap-python/snappy" Or get the source code from https://github.com/bcdev/jpy and follow the build instructions: git clone GitHub - bcdev/jpy: A bi-directional Python-Java bridge used to embed Java in CPython or the other way round.
$ cd jpy
ERROR: Configuration failed with exit code 10

Finally i try to follow this information from this post : Unable to install snappy - jpy problem? - #27 by arnab

1-Download and install Anaconda 3 2020.02 (to get python 3.7 directly)

2-Download and install git

3-Download and install maven

4-Download and install sentinelsat

5-Download and install the latest version of SNAP toolboxes, configure it with the python.exe of Anaconda 3

6-Download and install Visual studio C++ v14 or greater https://visualstudio.microsoft.com/visual-cpp-build-tools/

7-cd to C\user.snap\snap-python\snappy and: git clone https://github.com/bcdev/jpy.git

8-cd to C\user.snap\snap-python\snappy\jpy and: python setup.py bdist_wheel
(if it raises an error such as “JAVA_HOME ext folder exists” then remove the “ext” folder placed where the cmd “echo %JAVA_HOME%” return

9-copy to …snap\snap-python\snappy the .whl file at …snap\snap-python\snappy\jpy\dist

10-cd to C\user.snap\snap-python\snappy and: python setup.py install, then: pip install <.whl file>

11-cd to C:\Program Files\snap\bin and: snappy-conf.bat <path to python.exe of Anaconda 3>

12-copy to Anaconda3\Lib\site-packages\snappy the files at …snap\snap-python\snappy

but in step 11 i take some error .

Any idea ?it is python version error ?need only python 3.6 version ?

Thanks

1 Like

With Ubuntu 20.04 64-bit you don’t need Anaconda Python. The instructions you followed don’t make sense (Microsoft Visual Studio C++ is for Windows, not Ubuntu). See https://github.com/jpy-consortium/jpy for current instructions, but now that the number of gpt operators has greatly expanded, you may not need snappy at all. You may want to look into Snapista :: Anaconda.org.

the step with Microsoft Visual Studio C++ ignored it .
i dont use anaconda ,i use simple python 3.8.
In my python version i can import jpy package without errors.

import jpy

I can not make sense with this error.

Please start over again and tell us what you actually did. It is impossible to understand your problem without a clear statement of the the steps leading up to the failure. What is the name of the generated jpy .whl file?

Please upload ~/.snap/snap-python/snappy/snappyutil.log so we can see details of the error.

  1. Install conda
  2. Create environment.yaml file with this content

name: snap8
channels:

  • terradue
  • conda-forge
  • defaults
    dependencies:
  • python=3.8
  • snap==8.0.0
  • geopandas
  • pip
  • pip:
    • jupyterlab
    • scikit-learn
    • seaborn

After that write in the terminal:

sudo apt install snaphu
conda activate base
conda env create -f ./environment.yaml
conda activate snap8
python -m ipykernel install --user --name snap8 --display-name “Python3 (snap8)”

enjoy.

step by step

1-Download and install Snap 8.0 Unix 64-bit using this link How to install ESA SNAP on Ubuntu Linux | GIS-Blog.com

2-Download and install git

3-Download and install maven

4-Download and install sentinelsat

5-cd to C\user.snap\snap-python\snappy and: git clone https://github.com/bcdev/jpy.git

6-cd to C\user.snap\snap-python\snappy\jpy and: python setup.py bdist_wheel
(if it raises an error such as “JAVA_HOME ext folder exists” then remove the “ext” folder placed where the cmd “echo %JAVA_HOME%” return

7-copy to …snap\snap-python\snappy the jpy-0.10.0.dev1-cp38-cp38-linux_x86_64.whl file at …snap\snap-python\snappy\jpy\dist

8-cd to C\user.snap\snap-python\snappy and: python3 setup.py install, then: pip3 install jpy-0.10.0.dev1-cp38-cp38-linux_x86_64.whl

9-./snappy-conf /usr/bin/python3 /home/saran/.snap/snap-python/snappy

10-copy to Anaconda3\Lib\site-packages\snappy the files at …snap\snap-python\snappy

In snappyutil.log :

INFO: Installing from Java module ‘/home/username/snap/snap/modules/org-esa-snap-snap-python.jar’
WARNING: Architecture requirement possibly not met: Python is x86_64 but JVM requires amd64
INFO: Installing jpy…
ERROR: The module ‘jpy’ is required to run snappy, but no binary ‘jpy’ wheel matching the pattern
‘jpy-{version}-cp38-{abi_tag}-linux_x86_64.whl’ could be found.
You can try to build a ‘jpy’ wheel yourself, then copy it into
“/home/saran/.snap/snap-python/snappy”, and then run the configuration again.
Unzip the jpy sources in /home/username/.snap/snap-python/snappy/jpy-.zip, then
cdjpy− python setup.py bdist_wheel
cpdist/∗.whl"/home/username/.snap/snap−python/snappy"Orgetthesourcecodefromhttps://github.com/bcdev/jpyandfollowthebuildinstructions: git clone GitHub - bcdev/jpy: A bi-directional Python-Java bridge used to embed Java in CPython or the other way round.
$ cd jpy
ERROR: Configuration failed with exit code 10

tanajewski

I would not like to use anaconda because I have already built a project on python3, unless there is a way to use python3 and anaconda on the same project ?

thanx

You appear to be blinding copying commands without taking time to understand what they doing.
Unfortunately, some of the commands are not appropriate.

Those instructions are dated 2017. Stick with the current “official” instructions

Step 6:

is a Windows command .

Step 7 gives the same name for the binary wheel that I get.

You don’t need the pip3 install jpy-0.10.0.dev1-cp38-cp38-linux_x86_64.whl. Did you remove
this file before running snappy-conf?

Step 10 – this may be mixing ESA SNAP snappy with Anacoda’s snappy (a file compression library).
If you are using the distro python /usr/bin/python3 you should not put ESA SNAP snappy into Anaconda.

yes you are right is wring copy-paste .Sorry for that

JAVA_HOME
export JDK_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64
export PATH=PATH:{JAVA_HOME}/bin
export JAVA_HOME=${JDK_HOME}
export JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64/bin

I don’t remove this file jpy-0.10.0.dev1-cp38-cp38-linux_x86_64.whl before running snappy-conf.
Is still there

You can’t have spaces in the PATH setting, and you need $PATH and $JAVA_HOME/bin on the right-hand side:
export PATH="$PATH:<added_directory>" The double quotes are needed if a PATH component has spaces. Adding JAVA_HOME at the probably does nothing as you probably have java commands in some existing PATH component.

This probably means that the python program used to run snappy_conf was not the one used to build the binary wheel. This is a very easy trap to fall into as many systems end up with multiple Python versions installed. PEP 425 – Compatibility Tags for Built Distributions | Python.org explains the ABI tags. Note that Anaconda python 3.8 is generally not interchangeable with a distribution python 3.8 because Anaconda provides its own runtime libraries.

i dont have multiple Python in my system and i have jpy in python where i use to run snappy_conf.
if i run this command in terminal pip3 list.

then i take this :

jpy 0.10.0.dev1

I want to reinstall snap again to star over from begin .
My problem is For higher Python version it needs a manual build of jpy .
i think in this manual build i choose wrong way.Maybe to help me in this step for commands to build.

Thank you for your time to help me I really appreciate it .

Are you sure you really need snappy? Snappy was important several years ago, but now gpt has many more operators, so has replaced many snappy uses. As you have seen, snappy can be tricky to get working. Teradue snapista makes it easy to create gpt graphs using python tools.

Your build of jpy looks good, but may not have used the same python as you used with snappy_conf. You should check again for multiple Python versions: ls -l /usr/bin/python*, which -a python, and which -a python3. Various linux packages depend on different python versions, and there are often system tools that require an older version of python,
so I never encounter systems with only one version of python. After upgrading Ubuntu to 21.04 I have two versions of python:

gwhite(hippo)@gwlaptop /mnt/c/Users/gwhite
 % ls /usr/bin/python*
/usr/bin/python3  /usr/bin/python3-config  /usr/bin/python3.10  /usr/bin/python3.10-config  /usr/bin/python3.9  /usr/bin/python3.9-config
 % ls -l /usr/bin/python
ls: cannot access '/usr/bin/python': No such file or directory

On older versions of Ubuntu, ‘/usr/bin/python’ could be python2.7, and python3 should be the oldest python 3.x version and is used by “system” scripts.

Having jpy installed in Python shouldn’t hurt, but snappy_conf looks for the binary wheel and installs jpy in the $HOME/.snap/snap-python/snappy directory. You have not been consistent in your use of python:

I don’t think this is a problem, since snappy will use the jpy install in the snappy directory. Using pip3 is one of those bad practices being propagated on internet sites. You should use /usr/bin/python3.x -m pip to ensure that the installation goes to the desired python version.

i dont know about gpt.
I would like to use the reflectance tool for automatic correction of sentinel images with python, if I can do it with gpt tell me how?
can i do auto reflectance sentinel images with gpt and python?

thank you

Do you mean the ICOR plugin? Then you do need snappy_conf to work, but I think you can also run ICOR as a standalone system using Python without snappy.

hello again

i reinstall snap and i get some error :

INFO: Installing from Java module ‘/home/username/snap/snap/modules/org-esa-snap-snap-python.jar’
WARNING: Architecture requirement possibly not met: Python is x86_64 but JVM requires amd64
INFO: Installing jpy…
ERROR: The module ‘jpy’ is required to run snappy, but no binary ‘jpy’ wheel matching the pattern
‘jpy-{version}-cp38-{abi_tag}-linux_x86_64.whl’ could be found.
You can try to build a ‘jpy’ wheel yourself, then copy it into
“/home/username/.snap/snap-python/snappy”, and then run the configuration again.
Unzip the jpy sources in /home/username/.snap/snap-python/snappy/jpy-.zip, then
cdjpy− python setup.py bdist_wheel
cpdist/∗.whl"/home/username/.snap/snap−python/snappy"Orgetthesourcecodefromhttps://github.com/bcdev/jpyandfollowthebuildinstructions: git clone GitHub - bcdev/jpy: A bi-directional Python-Java bridge used to embed Java in CPython or the other way round.
$ cd jpy
ERROR: Configuration failed with exit code 10

in ls /usr/bin/python* i get :

/usr/bin/python3 /usr/bin/python3.8-config /usr/bin/python3-futurize
/usr/bin/python3.8 /usr/bin/python3-config /usr/bin/python3-pasteurize

and is 64 bit version all.

really i don’t know where is the wrong.

step 1 install snap 64 bit version
step 2 in step configure your Python installation i put my path /usr/bin/python3
step 3 restart
step 4 i create folder with name jpy in this path /home/username/.snap/snap-python/snappy
step 5 download this https://github.com/jpy-consortium/jpy#readme and extract in /home/username/.snap/snap-python/snappy/jpy
step 6 setup.py build maven bdist_wheel
step 7 ./snappy-conf /usr/bin/python3 and error 10

java paths :
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export JDK_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export PATH=$PATH:${JAVA_HOME}/bin
export PATH=$PATH:${JDK_HOME}/bin

Looks like you are 95% of the way to success. After step 6 you should have:

ls ~/.snap/snap-python/snappy/jpy/dist
jpy-0.10.0.dev1-cp38-cp38-linux_x86_64.whl

Before running setup.py (step 6) you need to copy the binary wheel to ~/.snap/snap-python/snappy.

In step 7 I recommend using ./snappy-conf /usr/bin/python3.8 (just to start making a habit out of being careful about minor versions in case something pulls in a newer python).

Note that there are now multiple python packages called snappy. To avoid conflicts and make it clear which snappy is being used by your script, you can use the
option to "append <snappy-dir> to the sys.path variable in your Python code before importing snappy" described in Configure Python to use the SNAP-Python (snappy) interface. Note that linux users need to replace USERPROFILE with HOME in the example code.

hello,

Finally i don’t know how but i think i get success message :

Done. The SNAP-Python interface is located in '/root/.snap/snap-python/snappy/snappy'
When using SNAP from Python, either do: sys.path.append('/root/.snap/snap-python/snappy')
or copy the 'snappy' module into your Python's 'site-packages' directory.

but any time know in python i get this error :

import sys
import os
sys.path.append('/root/.snap/snap-python/snappy')
import snappy
from snappy import ProductIO

error :

    raise IOError("Can't find SNAP distribution directory. Either configure variable 'snap_home' " +
OSError: Can't find SNAP distribution directory. Either configure variable 'snap_home' in file './snappy.ini' or set environment variable 'SNAP_HOME' to an existing SNAP distribution directory.

I need some more step like this :

cd ~/.snap/snap-python/snappy
python3 setup.py install

or :

copy to /usr/local/lib/python3.8/dist-packages/snappy/ the files at …snap\s

any idea ?

I define correct paths

export SNAP_HOME=/usr/local/snap
export PATH=$PATH:${SNAP_HOME}

and i take some error

You appear to have run some part of the install process as the “root” user (e.g., using the sudo command). Files under the /root directory are not available to normal users. There is also a trend to add restrictions to limit what the root account can do. Use of sudo and su to run regular applications is strongly discouraged.

ok but the error message is for snap home i think