Snappy Installation in Ubuntu

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. Any suggestions/edits would be appreciated.

To install snappy in ubuntu 22.04, and 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 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 on how to fix it by searching this forum. In short, 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 an 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!

1 Like

You should not need sudo to edit a regular user’s ~/.profile or ~/.bashrc or to make a user’s file executable. If the operations won’t work without using sudo there are likely other permission problems.

If you edited ~/.profile, you may need to log out and back in to get the settings. If you edited ~/.bashrc, you only need to open a fresh terminal. You can check these settings
by running echo $<variable_name> in a terminal.
If you

1 Like

Hello, @smahdavi ,
Thanks for sharing your steps.
As you use conda env, the other choice would be using: $ conda install -c terradue jpy
But you will then need to copy it from your environment to the snappy directory: cp ~/ananda3/envs/<env_name>/jpy_wheel/jpy*.whl ~/.snap/snap-python/snappy/
(Well, if you forget to do so, the error message will also remind you.)

Btw you can use `` for putting the path or scripts (2 for in line scripts, 6 for block scripts), so that it is easier to read. :wink:

1 Like