Problem with Snappy and error

سئو
Hello friends
I’m new to the community
Thanks for this active community

I have used the instrcutions how to install and configure snappy but when i try to run the following commands
from snappy import ProductIO
import numpy as np

I get the followng error
Traceback (most recent call last):
File “<pyshell#6>”, line 1, in
from snappy import ProductIO
ImportError: No module named snappy

Any ideas? :slightly_smiling_face: :rose:

thanks

Welcome at the SNAP community siavash82ir!

Probably the part in the section Configure Python did not work.
Maybe you have more than one Python installation and you have configured a different one as the one you use with your script.

2 Likes

Hi Marco,

I have same error, firstly I have installed miniconda 3.7, then I created py2 environment, during installing SNAP, I selected python2 as python executable,

following the instructions in here Configure Python

Firstly I navigated to the snappy folder and activated py2 , and execute python, then I tried this command $ from snappy import ProductIO

But I got an error, so how to activate snappy in order to use it?

Also might be @johngan and @ABraun they could give some hints

it is from and not form :slight_smile:

Yes, I mistyped it, but still I got an error, the error is,

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

Even when I tried up to append sys, the same error,

I see, sorry.

In case you created a python2.7 environment (py2) a new directory should appear in anaconda\envs\py2 with a python.exe in it.
When you configure SNAP for the use with python as in the link above you have to make sure that you use this path, e.g. like this:
snappy-conf C:\anaconda\envs\py2\python.exe

otherwise, the snappy libraries are installed elswhere

HI,

It seems that snappy has not been properly configure. You have mentioned that you use anaconda, so, you can create a virtual environment and install snappy in there. You can do the following:

  • create a virtual environment (conda crate -n snappy python=3.4). This command will create a virtual environment called snappy with python version 3.4. snappy does not work with a higher python version

  • configure python with SNAP.

  1. cd snap/bin
  2. /snappy-conf/full path of python interpreter (in my case: ./snappy-conf /home/miniconda3/envs/snappy/bin/python)
  • copy snappy folder into site-package of the virtual environment
    cp -R snappy /home/miniconda3/envs/snappy/lib/python3.4/site-packages

snappy location: ~/.snap/snap-python/snappy

now snappy module is contained in the conda virtual environment.

I hope that helps

Yes, I used similar path exactly,

My snappy folder is founded in here, C:\Users\FALAH FAKHRI.snap\snap-python\snappy

I already configured the py2 during the SNAP installation,

My snappy is available in the following path,

My snappy folder is founded in here, C:\Users\FALAH FAKHRI.snap\snap-python\snappy

I tried to apply this code,

conda create -n snappy python=3.4 but I got the following error, so what do you suggest in this case,

I checked up the list of env,

I would suggest you to re-install SNAP and select python 3 for configuration not pytho2. Then follow the same steps of conda virtual environment creation

I firstly removed py2 env, and then I uninstalled SNAP, reinstalled SNAP, and select python.exe, (3.7), what I already installed, but again the same error,

The terminal is complaining about gaps in your path. When working with a programming language, it is good not to leave gaps in your path. Instead of FALAH FAKHRI, it can be changed to FALAH_FAKHRI.

It also complains about vs2010_runtime conflict. I think this might be the Microsof visual C++ redistribution pacakge which is required for some applications on your PC. I do not know if you download a new version of this will solve the problem (https://www.microsoft.com/en-gb/download/details.aspx?id=5555).

If you cannot manage to make it work with anacoda, i would suggest you to use pipenv as an alternative. pipenv is teh official recommended python packaging tool. It resolves all the issues regarding python package versions.

have a look at his:

It could be risky, I also have asked the micorsoft supporters,

I checked it up and the newer version is available in my pc.,

I installed it, But what is the step after that?

you can create a virtual environment with all the python packages you need as follows:

  • create a folder in the directory (e.g my_project)
  • install the desirable python version: pipenv --python 3.4. Make sure python 3.4 is installed in your machine
  • install python packages (e.g pipenv numpy scipy rasterio e.t.c)
  • start the virtual environment: pipenv shell

if everything runs smoothly in your environment, then you can add the snappy path in python (sys.path.append(path to snappy folder))

Try the above and see what happens.

Python 3.4 Not exist or I didn’t find it, from here (installer), in order to install it separately in my machine,

I tried up to follow your instructions, to install python 3.4, accordingly I tried,

$ conda create --name py3 python=3.4

But I didn’t succeed to install it receiving the following message,

I didn’t succeed because python 3.4 is not exist

Right, first of all, before starting creating virtual environments, we need to make sure that you have configured snappy correctly. I suspect that snappy has not been configured correctly. Let’s make sure that the steps you followed for the configuration are correct.

  1. Install SNAP and configure it with python 3

  2. Install python 3.4 in your system.: Unfortunately, snappy does not work with the latest version of python. Python 3.4 does not provide a windows installer, hence, we need to build it from source. To do that, we need to perform the following steps:

    • Download python 3.4.5 from here
    • Scroll all the way down on the bottom and click on Gzipped source tarball
    • unzip the folder
    • go inside the folder you downloaded: Python-3.4.5 and open a terminal
    • type: ../configure --with-pydebug
    • type: make
    • type: make test
      There is also a README file in the folder telling you how to build python.
  3. snappy configuration

    • cd snap/bin
    • ./snappy-conf ‘full path of python interpreter’. Find the python 3.4.5 installation path and paste it next to snappy-conf.

Hopefully, these steps will work for you. Trying to work with programming languages in windows is bit nightmare compare to linux. It requires lots of effort.

2 Likes

Thanks a lot for very nice instructions, However, I didn’t succeed to go further than, the highlighted readme makes the the issue more complicated for me, but what I did is following your smooth nice instructions.

check the following two resources on how to fix this:

But in my case the windows\system32 is already defined,

your path C:\Windows\system32, it looks like the system32 stars with lower case ‘s’. I do not know your windows path names but looking all of your paths it seems that system32 should start with capital ‘S’.
Might worth changing C:\Windows\system32 to C:\Windows\System32. and try to build the python from source
If again this does not work, it might need an update version of java