Unable to install snappy - jpy problem?

I think you need to call python setup.py --maven bdist_wheel
See: https://github.com/bcdev/jpy/blob/master/README.md#how-to-build-on-linux-and-mac

$ export JDK_HOME=<your-jdk-dir>
$ export JAVA_HOME=$JDK_HOME
$ python get-pip.py
$ python setup.py --maven bdist_wheel

Thanks Marco, The suggested commands were accepted by the one machine (OSX 10.12) then I had to run from the office. Here at my other office, I am trying to install on another machine (OSX 10.9) where I was also to the point in the debugging that I had installed JDK. So picking up from there…

$ export JDK_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/
$ export JAVA_HOME=$JDK_HOME
$ which python
/opt/local/bin/python

$ cd /Applications/snap/bin
$ ./snappy-conf /opt/local/bin/python
Configuring SNAP-Python interface…
java.io.IOException: Python configuration failed.
Command [/opt/local/bin/python ./snappyutil.py --snap_home /Applications/snap --java_module /Applications/snap/snap/modules/org-esa-snap-snap-python.jar --force --log_file ./snappyutil.log --java_home /Applications/snap/.install4j/jre.bundle/Contents/Home/jre --req_arch x86_64]
failed with return code 10.
Please check the log file ‘/Users/jasonbox/.snap/snap-python/snappy/snappyutil.log’.
at org.esa.snap.python.PyBridge.configureJpy(PyBridge.java:223)
at org.esa.snap.python.PyBridge.installPythonModule(PyBridge.java:147)
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:745)
Python configuration error: Python configuration failed.
Command [/opt/local/bin/python ./snappyutil.py --snap_home /Applications/snap --java_module /Applications/snap/snap/modules/org-esa-snap-snap-python.jar --force --log_file ./snappyutil.log --java_home /Applications/snap/.install4j/jre.bundle/Contents/Home/jre --req_arch x86_64]
failed with return code 10.
Please check the log file ‘/Users/jasonbox/.snap/snap-python/snappy/snappyutil.log’.

$ cat /Users/jasonbox/.snap/snap-python/snappy/snappyutil.log
INFO: Installing from Java module ‘/Applications/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}-cp34-{abi_tag}-macosx_10_9_x86_64.whl’ could be found.
You can try to build a ‘jpy’ wheel yourself and then copy it into
“/Users/jasonbox/.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 “/Users/jasonbox/.snap/snap-python/snappy”
ERROR: Configuration failed

$ git clone https://github.com/bcdev/jpy.git
Cloning into ‘jpy’…
remote: Counting objects: 5242, done.
remote: Total 5242 (delta 0), reused 0 (delta 0), pack-reused 5242
Receiving objects: 100% (5242/5242), 2.04 MiB | 511.00 KiB/s, done.
Resolving deltas: 100% (2942/2942), done.
Checking connectivity… done.
$ cd jpy
$ python setup.py bdist_wheel
Traceback (most recent call last):
File “setup.py”, line 25, in
from setuptools import setup
ImportError: No module named ‘setuptools’

… and so I came back to the following…
python get-pip.py
Collecting pip
Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 400kB/s
Collecting setuptools
Downloading setuptools-36.2.0-py2.py3-none-any.whl (477kB)
100% |████████████████████████████████| 479kB 856kB/s
Collecting wheel
Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
100% |████████████████████████████████| 69kB 2.3MB/s
Installing collected packages: pip, setuptools, wheel
Exception:
Traceback (most recent call last):
File “/var/folders/vw/lmkw2l0s1tx6vs5sk99vx5nc0000gn/T/tmpnyv94inb/pip.zip/pip/basecommand.py”, line 211, in main
status = self.run(options, args)
File “/var/folders/vw/lmkw2l0s1tx6vs5sk99vx5nc0000gn/T/tmpnyv94inb/pip.zip/pip/commands/install.py”, line 311, in run
root=options.root_path,
File “/var/folders/vw/lmkw2l0s1tx6vs5sk99vx5nc0000gn/T/tmpnyv94inb/pip.zip/pip/req/req_set.py”, line 646, in install
**kwargs
File “/var/folders/vw/lmkw2l0s1tx6vs5sk99vx5nc0000gn/T/tmpnyv94inb/pip.zip/pip/req/req_install.py”, line 803, in install
self.move_wheel_files(self.source_dir, root=root)
File “/var/folders/vw/lmkw2l0s1tx6vs5sk99vx5nc0000gn/T/tmpnyv94inb/pip.zip/pip/req/req_install.py”, line 998, in move_wheel_files
isolated=self.isolated,
File “/var/folders/vw/lmkw2l0s1tx6vs5sk99vx5nc0000gn/T/tmpnyv94inb/pip.zip/pip/wheel.py”, line 339, in move_wheel_files
clobber(source, lib_dir, True)
File “/var/folders/vw/lmkw2l0s1tx6vs5sk99vx5nc0000gn/T/tmpnyv94inb/pip.zip/pip/wheel.py”, line 310, in clobber
ensure_dir(destdir)
File “/var/folders/vw/lmkw2l0s1tx6vs5sk99vx5nc0000gn/T/tmpnyv94inb/pip.zip/pip/utils/init.py”, line 71, in ensure_dir
os.makedirs(path)
File “/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/os.py”, line 237, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: ‘/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip’

jpy$ python setup.py --maven bdist_wheel
Traceback (most recent call last):
File “setup.py”, line 25, in
from setuptools import setup
ImportError: No module named ‘setuptools’

jpy$ ls
CHANGES.md README.md doc jpyutil.py setup.cfg winbuild.cmd
LICENSE.txt appveyor.yml ez_setup.py pom.xml setup.py
MANIFEST.in ci get-pip.py pysobug src

at this point, I welcome any pointers.

With appreciation,

Jason

Try

sudo python get-pip.py

The might help, because I see PermissionError: [Errno 13] Permission denied in your logs.

Thanks Marco,

That sudo indeed helped get that part in…

returning to…

$ ./snappy-conf /opt/local/bin/python
Configuring SNAP-Python interface…
java.io.IOException: Python configuration failed.
Command [/opt/local/bin/python ./snappyutil.py --snap_home /Applications/snap --java_module /Applications/snap/snap/modules/org-esa-snap-snap-python.jar --force --log_file ./snappyutil.log --java_home /Applications/snap/.install4j/jre.bundle/Contents/Home/jre --req_arch x86_64]
failed with return code 10.
Please check the log file ‘/Users/jasonbox/.snap/snap-python/snappy/snappyutil.log’.
at org.esa.snap.python.PyBridge.configureJpy(PyBridge.java:223)
at org.esa.snap.python.PyBridge.installPythonModule(PyBridge.java:147)
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:745)
Python configuration error: Python configuration failed.
Command [/opt/local/bin/python ./snappyutil.py --snap_home /Applications/snap --java_module /Applications/snap/snap/modules/org-esa-snap-snap-python.jar --force --log_file ./snappyutil.log --java_home /Applications/snap/.install4j/jre.bundle/Contents/Home/jre --req_arch x86_64]
failed with return code 10.
Please check the log file ‘/Users/jasonbox/.snap/snap-python/snappy/snappyutil.log’

$ cat /Users/jasonbox/.snap/snap-python/snappy/snappyutil.log
INFO: Installing from Java module ‘/Applications/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}-cp34-{abi_tag}-macosx_10_9_x86_64.whl’ could be found.
You can try to build a ‘jpy’ wheel yourself and then copy it into
“/Users/jasonbox/.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 “/Users/jasonbox/.snap/snap-python/snappy”
ERROR: Configuration failed

the following is strange since JDK 1.8 is live?..

$ python setup.py --maven bdist_wheel
Error: environment variable “JAVA_HOME” must be set to a JDK (>= v1.7) installation directory
$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/
$ echo $JDK_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/

back installing on the OSX 10.12 machine name aput, working through anaconda per collaborators suggestion…

I got the JPY wheel turning, it seems. :slight_smile:

latest hang up I request input on:

$source activate esa_dev # anaconda environment
(esa_dev) aput:bin jason$ ./snappy-conf /Users/jason/anaconda3/bin/python
Configuring SNAP-Python interface…
Done. The SNAP-Python interface is located in ‘/Users/jason/.snap/snap-python/snappy’
When using SNAP from Python, either do: sys.path.append(’/Users/jason/.snap/snap-python’)
or copy the ‘snappy’ module into your Python’s ‘site-packages’ directory.

My question is if snappy.ini is the “snappy module”?

in that case, I try

cp /Users/jason/.snap/snap-python/snappy/snappy.ini /users/jason//anaconda3/envs/esa_dev/lib/python3.4/site-packages

after that…
(esa_dev) aput:snap jason$ python
Python 3.4.5 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:47:57)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.

import snappy
Traceback (most recent call last):
File “”, line 1, in
ImportError: No module named 'snappy

any suggestions?

Nice that the wheels turns…

snappy.ini is not the module. The complete snappy directory located snap-python is the module.
If you copy this it should work. *fingerscrossed*

I’m in business!!

What I hope can help others I sketch what I did on the OSX 10.12 Sierra Mac

Start by installing the following…

  1. python 3.4
  2. Anaconda
  3. JRE
  4. JDK (Java Development ToolKiit) I installed jdk-8uversion-macosx-x64.dmg
  5. SNAP latest version
  6. Xcode developer latest version

more…
sudo git clone https://github.com/bcdev/jpy.git
cd jpy
sudo python setup.py bdist_wheel
cp dist/*.whl “~/.snap/snap-python/snappy”

conda create --name esa_dev python=3.4

$ which python
~/anaconda3/bin/python
$ cd /Applications/snap/bin
(esa_dev) aput:bin jason$ ./snappy-conf /Users/jason/anaconda3/envs/esa_dev/bin/p

conda install --name esa_dev math numpy
conda install --name esa_dev mpmath numpy

these put in Mac .profile
export JDK_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/
export JAVA_HOME=$JDK_HOME
export PYTHONPATH=$PYTHONPATH:/Users/jason/.snap/snap-python/
source .profile

Anaconda How To…
Unix:
source activate esa_dev
[else on exit source deactivate esa_dev]

cd /Applications/snap/bin/
./snappy-conf ~/anaconda3/envs/esa_dev2/bin/python

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

now execute your snappy .py scripts!

3 Likes

Glad you got it working. Thanks for posting the details. The same approach should work for El Capitan. A few items may need clarification/simplification for anyone who comes across this post in the future:

Under “Start by installing”

  1. python3.4

Python 3.4 is available from several sources (macports, homebrew, or python.org). You seem to using an Anaconda
environment. Did you start with Anaconda2 or Anaconda3 (or does it matter?). Mabe you meant:

  1. install Anaconda2 or Anaconda3 python (depending on whether you want to have 2.7 or 3.6 as your default version).
  2. configure an Anaconda python=3.4 environment for snappy

You shouldn’t need to use “sudo” to run “python setup.py bdist_wheel”, but I would think
that needs to be done using the esa_dev (python=3.4) environment.

Java has been getting regular updates on current macOS. In the .profile file you can use:

export JDK_HOME="${JDK_HOME:-$(/usr/libexec/java_home)}"

This should automatically switch to the new Java version at login.

1 Like

Dear All,

I’ve just set up snap for the first time on a clean OS X Sierra computer with the following commands. Homebrew and Anaconda python were already installed, and the Mac OS X JDK (jdk-8u144-macosx-x64.dmg) from http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html , then:

conda create -n SNAP python=3.4
source activate SNAP

# install maven
brew install maven

# install jpy
cd local/src/
git clone https://github.com/bcdev/jpy.git
cd jpy/
python setup.py bdist_wheel
cp dist/*.whl ~/.snap/snap-python/snappy

# set up snappy
# NOTE: customize paths here to where SNAP and Anaconda are installed
~/Applications/snap/bin/snappy-conf ~/local/anaconda/envs/SNAP/bin/python

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

# I think here OS X told me it needed a legacy java and sent me to a webpage. I installed:
# https://support.apple.com/kb/DL1572?locale=en_US

# test
python
import snappy # no error message = works.
2 Likes

Hi! I am still getting the error “Error: environment variable “JAVA_HOME” must be set to a JDK (>= v1.7) installation directory”

and my version is jdk-12.0.1.jdk.

Do you remember how to solve this error?

Thanks a lot!

Please try it with a JDK 8 from Oracle. Not sure if it can work with a JDK greater then 8. Also OpenJDK can make problems.

2 Likes

Thanks for the reply!

(SNAP) Rochelles-MBP:jpy rochellecostasilva$ sudo python setup.py --maven bdist_wheel

Error: environment variable “JAVA_HOME” must be set to a JDK (>= v1.7) installation directory

(SNAP) Rochelles-MBP:jpy rochellecostasilva$ echo $JAVA_HOME

/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home

Already changed the JDK for 8 and it is from Oracle, but I still get the same error.

Did you export JAVA_HOME? Please run “export -p | grep JAVA_HOME” to verify that
the variable is exported.

I get this:

   $ export -p | grep JAVA_HOME
    declare -x JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home"

Good, the setting should be visible to python. The next problem to consider is the use of “sudo”, which gives you a different environment. Have you tried your command without “sudo”. Snappy is installed in the user’s ~/.snap directory so sudo should not be used. You may need to reset ownership to yourself in the ~/.snap tree.

I am facing the same issue on my Ubuntu system but I am unable to resolve it using the steps mentioned here. I am attaching the necessary screenshots from my process.
@marpet @jasonbox

jdk

Looking forward.

SNAP provides binary wheels for jpy, but only python 2.7 and a few python 3 versions up to 3.6. You can install Anaconda3’s python 3.6 environment to use an existing binary wheel or try building jpy as described in snappyutil.log with a more recent python.

1 Like

if you can use conda, try:

conda install -n -c terradue jpy

It supports python 3.7, 3.8 and 3.9

2 Likes

Good to know :slight_smile:

Not sure that it’s the right place to put this, but as I spent hours, even days to solve multiple errors that we can find here, let me write this small tutorial from a beginner to beginners.

It’s only useful if you use or want to use the Anaconda distribution, which is highly recommended on Windows. It’s not perfect, but summarise basically what you need to do from scratch until getting SNAP and snappy installed and configured.

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

You’re done!

2 Likes