Hi, I’ve just recently started using snappy. I’m currently running snappy with Python 3.6 with Anaconda (which I pushed to Jupyter Notebook using python -m ipykernel install --user --name=py36
), following this tutorial: https://senbox.atlassian.net/wiki/spaces/SNAP/pages/50855941/Configure+Python+to+use+the+SNAP-Python+snappy+interface
The code I’m trying to run is this very simple piece of code below:
import sys
sys.path.append('C:\\Users\\Conor\\.snap\\snap-python')
import numpy as np
from snappy import ProductIO
testfile= '../../data/Edited_Copernicus/S2B_MSIL2A_20210906T112109_N0301_R037_T30UUU_20210906T125847_ndvi.dim'
product=ProductIO.readProduct(testfile)
width=product.getSceneRasterWidth()
height=product.getSceneRasterHeight()
print(width)
print(height)
This code runs just as expected in Anaconda Prompt but for some strange reason, when I try to run it in Jupyter Notebook I get an error relating to jpy. I’ve searched the forum and I’ve noticed a few people have had issues using jpy in general but for some odd reason snappy works just as expected in Anaconda Prompt. I was wondering if anyone has had any similar issues and if there are any known solutions to this problem.
Here is the error in full:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-15-d3cd7f96e261> in <module>
1 import numpy as np
----> 2 from snappy import ProductIO
3 testfile= '../../data/Edited_Copernicus/S2B_MSIL2A_20210906T112109_N0301_R037_T30UUU_20210906T125847_ndvi.dim'
4 product=ProductIO.readProduct(testfile)
5 width=product.getSceneRasterWidth()
~\.snap\snap-python\snappy\__init__.py in <module>
63
64 jpyutil.preload_jvm_dll()
---> 65 import jpy
66
67 if debug:
ModuleNotFoundError: No module named 'jpy'