I have been using the snappy library in Python without any problems until now, on a virtual machine. I have just been given a new desktop computer at work and can now work locally, but am now struggling to install Snappy.
I have setup Python with Anaconda 3, and followed the steps listed below:
Installed Java JRE and JDK 8, setup the environement variables
Installed SNAP
Installed jpy manually, as previously mentionned on this forum
Ran ./snappy-conf on my anaconda python path which yielded:
Done. The SNAP-Python interface is located in â/home/username/.snap/snap-python/snappyâ
Ran python setup.py install
When I start a python shell and type: import snappy , I get the following message:
Traceback (most recent call last):
File ââ, line 1, in
File â/home/username/.snap/snap-python/snappy/init.pyâ, line 64, in
import jpy
ImportError: /home/username/.snap/snap-python/snappy/jpy.so: undefined symbol: _Py_ZeroStruct
Which Python version are you running. The missing symbol seems to indicate that it is a 3.5+. Unfortunately, snappy Python bindings are for 3.4 only. We are working on this issue right now.
Thank you for your response. Indeed the problem was linked to the Python version. I have managed to complete the install in a Anaconda Virtual Env, using Python 3.4 .
Hi Maxim, do you have some tips regarding the snappy installation in the Anaconda virtual environment ? I canât have a successful install on my secondary py34 environment.
I tried installing snappy. My conclusion is that you can use snappy only if your start the script from the snappy interface folder. For example I have installed snappy on C:\UsersâŚsnappy\snappy-python, if I run the script anywhere on c:\ the script is working, if I move on D:\ then I canât use snappy and the script is not working. Iâm using an anaconda 3 py34 environment.
Do you have any other opinion ?
How have you integrated snappy into your anaconda environment?
Which of the steps have you done of the Configure Python
the section on the Configure Python to use the SNAP-Python (snappy) interface page. What kind of error do you get?
Iâve copied the snappy folder into the site-packages directory.
For me, it works also from another drive. See the image.
Second, Iâm resuming in the next rows the steps that Iâve used to enable snappy on Anaconda 3 (x64) .
I installed latest Apache Maven, Visual Studio from Microsoft and latest java client and jdk. Environment variables were configured:
User variables â Paths
C:\Program Files\apache\maven\bin
System variables
JAVA_HOME â C:\Program Files\Java\jdk1.8.0_172
JDK_HOME â JAVA_HOME
Full installed the ESA SNAP software without âConfigure SNAP for use with Pythonâ enabled;
Full updates for ESA SNAP;
The installation process created Environment variables â User variables â Paths â C:\Program Files\snap\bin
Full installed Anaconda 3 with Python 3.6
In Anaconda prompt I created a new python 3.4 environment.
activated python 3.4 new environment in anaconda 3;
While in py34 anaconda activated environment Iâve done the following steps:
installing jpy from the C:\Users\The Specialist position by using git clone;
from the same position I deployed: âsnappy-conf C:\Anaconda3\envs\py34\python.exeâ;
cd /snappy;
python setup.py install
copied the C:\Users\The Specialist.snap\snap-python\snappy directory directly into the site-packages directory
testing instalation from C:\Users\The Specialist position: python, import snappy â everything looks great and the my sentinel 2 project is working from this position
the importing result looks like the following:
(py34) C:\Users\The Specialist>python
Python 3.4.5 | packaged by conda-forge | (default, Sep 8 2016, 14:36:52) [MSC v.1600 64 bit (AMD64)] on win32
Type âhelpâ, âcopyrightâ, âcreditsâ or âlicenseâ for more information.
python â import snappy => the module is not loading properly (see the bellow output) and the sentinel 2 script is not working
I donât have sys append or something similar in my script;
(py34) C:\Users\The Specialist>d:
(py34) D:>python
Python 3.4.5 | packaged by conda-forge | (default, Sep 8 2016, 14:36:52) [MSC v.1600 64 bit (AMD64)] on win32
Type âhelpâ, âcopyrightâ, âcreditsâ or âlicenseâ for more information.
Okay, now I see the problem and I can reproduce it.
In general your snappy is working and you could use the API. The problem is that some modules are not loaded. I see the same behaviour when Iâm on my drive G. The S2RUT is not loaded in my case.
So it seems that modules installed later or updated are not considered.
I guess somewhere in snappy a wrong path is used. Iâll take look. (SNAP-929)
I forgot to mention that the reported issue was causing me also the necessity to write folders full paths in order to read/manipulate files from project location because I had to run the project from C:\ ⌠.
Now, I hope to get my project working straight from its location.
Just finished in dealing with the proposed solution.
Here are the steps that I pursued in having a clean and correct install of snappy, because there was an already installed version of the module (and I wanted to be sure that everything is ok).
First I uninstalled ESA SNAP, installed back without âConfigure SNAP for use with Pythonâ enabled.
2.
Run steps from âConfigure Python to use the SNAP-Python (snappy) interfaceâ (https://senbox.atlassian.net/wiki/spaces/SNAP/pages/50855941/Configure+Python+to+use+the+SNAP-Python+snappy+interface) until the step:
Windows: snappy-conf <python-exe>
3.
After the step 2) I have operated the proposed changes inside __init__.py
4.
After those changes I tried to permanently install snappy
cd /snappy
$ setup.py install
No other folder copy was needed.
Wonderfull, now, the snappy module can be used from any location/disk (see the attached picture). All additionally installed modules are imported. Now I can run my sentinel 2 project from itâs location, no full paths are needed inside the developed modules