ProductIO Import Error while using snappy in python


#1

while using snappy, ProductIO is not getting import.


#2

hi, can you be more specific over the error ?


#3

I am getting an “import error in ProductIO” while using snappy in python. Can you help?


Shape File in SNAP
#4

Only if you provide more information, e.g. a snippet of your source code.
Helpful can also be other threads in this forum:
https://forum.step.esa.int/search?q=shapefile%20%23development%3Apython


#5

image
This is a simple code I tried, and its showing import error : “ImportError: cannot import name ProductIO”


#6

Probably it is because of the path. Try an absolute Path to the file.


#7

Where should I point to?


#8

Where snappy is installed. I guess you copied it into the site-packages folder of your Python.
Probably here: C:\Python27\Lib\site-packages\snappy\testdata
Or it is still at C:\Users\<USER_HOME>\.snap\snap-python\snappy\testdata


#9

I moved it to where snappy was installed but still its showing the same error.
Is it something related to jpy?


#10

C:\Python27\Lib\site-packages\snappy , this is the location where snappy is installed.


#11

I had another look at the error message.
The problem is already the import of ProductIO.
Then something is probably wrong with the snappy installation.

In the snappy folder in the site-packages directory should be a file named snappyutil.log. Could you attach it here, please?

But still, absolute paths should be used. Then the script will work no matter where you invoke it.


#12

No, there’s no such file named snappyutil.log inside the site-packages.


#13

Then something went wrong during the configuration.
Even if you did already, could you follow this guide: Configure Python to use the SNAP-Python snappy interface Maybe it will work then.


#14

Sir, I followed all the configuration steps, still its not able to import ProductIO. I am getting the same error.


#15

It is able to import only the packages which are not inside any sub folder. It shows error for any package inside any sub folder. And also, I have not found ProductIO inside snappy anywhere. Is the problem because of this?


#16


#17

do you have other instances of Python installed on this computer?

Maybe the wrong installation gets called when you type “Python”. Plus, there is a second package called snappy which has different classes. What happens when you type

from snappy import CompressError

If this gives you no error, the wrong snappy is imported.

Try moving the directory of your python installation to the top of your PATH variable so it gets called first. https://www.computerhope.com/issues/ch000549.htm


#18

I have set the path again and still its the same error.


#19

Is it a problem with python 2.7 version?


#20

no, Python 2.7 is fine actually.
Are you sure that there are no other versions of python installed?

Did you try
from snappy import CompressError