Snappy first contact failed - no module named 'jpyutil'

I don’t get snappy to work and by now I’m frustrated. So, probably someone can help me.

I work in anaconda3 and I created a python3.4 environment. I installed numpy and I installed snappy with conda install -c anaconda python-snappy=0.5. I looked it up and it is in the modules list in python. Some time ago I tried it in an other way (without this conda-command and only in the snappy directory), but the problem stays the same.

I tried the ‘first contact’-test code, but it dosen’t work. I will show you what I’ve done and the ‘results’.

While being in the snappy directory & working with conda in python:
from snappy import ProductIO Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/mara/.snap/snap-python/snappy/__init__.py", line 61, in <module> import jpyutil ImportError: No module named 'jpyutil'

So, I tried to get jpy:

pip install -i https://pypi.anaconda.org/pypi/simple jpy Error: Environment variable "JDK_HOME" must be set to a JDK (>= v1.6) installation directory

I solved this problem. First I used this instruction [x] to install JDK 8 and created a symbolic link:
ln -s /opt/java/jdk1.8.0_111 /opt/java/latest
And being in the /opt/java directory:
export JDK_HOME=/opt/java/latest export JAVA_HOME=${JDK_HOME} export PATH=$PATH:${JAVA_HOME}/bin

But, at the end, I got a new error trying to install jpy via pip:
Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-build-p2voq_f8/jpy/setup.py", line 100, in <module> with open('README.rst') as file: FileNotFoundError: [Errno 2] No such file or directory: 'README.rst'

And I really don’t know how to solve this.

The setup.py script in the jpy-VER.zip file refers to README.rst, but there is no such file. Use pip download ... to download the jpv-VER.zip file. Create a jpy-VER/README.rst file and append it to the .zip file. I found VER=0.7.5, so:

$ pip-3.4 download jpy $ jar tvf jpy-0.7.5.zip [...] 2461 Wed May 07 13:22:14 ADT 2014 jpy-0.7.5/src/test/python/imp/import_ex2.py $ mkdir jpy-0.7.5 $ touch jpy-0.7.5/README.rst $ jar uvf jpy-0.7.5.zip jpy-0.7.5/*

I understand the problem and how you suggest me to solve it, but I don’t get the jpy-VER.zip file. (By the way: there is one typing error in your post. You wrote one time jpv.)
I assume ‘VER’ means the version-number.
pip download jpy-0.7.5.zip and pip download -i https://pypi.anaconda.org/pypi/simple/jpy jpy-0.7.5.zip gives the same error:
Requirement 'jpy-0.7.5.zip' looks like a filename, but the file does not exist Processing ./jpy-0.7.5.zip FileNotFoundError: [Errno 2] No such file or directory: '/home/mara/jpy-0.7.5.zip'

edit:

I downloaded the .zip file from the homepage and unpacked it. Thus there is a directory jpy-0.7.5.
Afterwards I followed your instructions
$ touch jpy-0.7.5/README.rst $ jar uvf jpy-0.7.5.zip jpy-0.7.5/*.

So, I thought I could try pip install jpy again, but nope. :unamused:
Collecting jpy Using cached jpy-0.7.5.zip Complete output from command python setup.py egg_info: Building a 64-bit library for a Linux system Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-build-4_zzv13s/jpy/setup.py", line 100, in <module> with open('README.rst') as file: FileNotFoundError: [Errno 2] No such file or directory: 'README.rst'

Thus, I go in the directory which I zipped before and there is an README.rst. And I searched and deleted every other .zip file for jpy without the README.rst. I don’t know why it dosen’t work.

have you tried manually downloading jpy and installing it with python setup.py install?

Did you have a look at the About the python category post? There you can find links to introductory wiki pages.
Especially Configure Python to use the SNAP-Python (snappy) interface can help you.

Please also note that the anaconda and the pypi package are not deployed by us but by enthusiastic users. This means there is no official support for this from our side.
However, we have plans to ease the installation and solve known issues. But this will be a bigger effort on our side. So I can’t give you a precise time schedule. But it should happen within the first half of this year.

@marpet: The second link is the link I was working with at the beginning. But I have to solve a lot of problems. I will have a look at your ‘about the python category’ post. Probably, it will help.

I know, that there is no official support, but one problem was that my linux mint sarah has python 3.5 and you are not supporting this version. Thus, I have to find an other way to make it work. And it’s pretty complicated.

And @ABraun: No. I havn’t tried it this way. I think this could be my next step.

I heard from others that they were able to use Python 3.5 on Unix and they had not to do anything special.
Sorry, can’t tell you more.

One more thing. I remembered that I read you support also anaconda in the configure python post. This was one reason for me to try it that way. Thats why I was a little bit confused about your commend.

Whatever, thanks for the help anyway. Probably I will try it on python3.5 and without anaconda.

I ran into the same problem when trying to install snappy in QGIS Python on Windows: https://github.com/senbox-org/snap-engine/issues/101

There do exist pre-built jpy wheels for various architecture and Python versions that you can install. And you need to point jpy to SNAP’s JRE.

Did you make any progress to ease the installation process ? i still get troubles to make it work (related to jpyutil)

In case someone still faces problems with snappy installation because of jpy, jpyutil etc, I recently managed to install it through a wheel found here: https://github.com/bcdev/jpy/releases
I placed it in a jpy directory where I wanted jpy to be installed , and then run pip install thewheel.whl. Remember that you probably need also the rest of prerequisites, at least Java and maven, to make it work. For the prerequisites, check here: https://jpy.readthedocs.io/en/latest/install.html
I work on windows.

Hope it helps.

1 Like

Did you manage to configure Snnapy to use it within QGIS?