johntruckenbrodt / pyroSAR

framework for large-scale SAR satellite data processing
MIT License
494 stars 110 forks source link

RuntimeError: cannot read version information from. Please restart SNAP. #315

Closed nikkopante closed 2 months ago

nikkopante commented 2 months ago

Hi all! I am trying to use the pyrosar tool in Jupyter Notebook. However, I get an error that it cannot read the current version of SNAP. I just installed SNAP after I install the tool in conda.

from pyroSAR.snap import geocode

filename = '../data/S1A_IW_SLC__1SDV_20240604T214715_20240604T214742_054179_0696C0_AFCF.zip'
outputfile = '../results/output.tif'

test = geocode(filename, outputfile, polarizations=['VV', 'VH'], terrainFlattening=True, refarea='gamma0')

Here is the error:

File ~\anaconda3\envs\dpad\Lib\site-packages\pyroSAR\snap\auxil.py:91, in parse_node(name, use_existing)
     67 """
     68 parse an XML node recipe. The XML representation and parameter default values are read from the docstring of an
     69 individual node by calling `gpt <node> -h`. The result is then written to an XML text file under
   (...)
     88 {'selectedPolarisations': None, 'removeThermalNoise': 'true', 'reIntroduceThermalNoise': 'false'}
     89 """
     90 snap = ExamineSnap()
---> 91 version = snap.get_version('s1tbx')['version']
     92 name = name if name.endswith('.xml') else name + '.xml'
     93 operator = os.path.splitext(name)[0]

File ~\anaconda3\envs\dpad\Lib\site-packages\pyroSAR\examine.py:368, in ExamineSnap.get_version(self, module)
    366 match = re.search(pattern, content)
    367 if match is None:
--> 368     raise RuntimeError('cannot read version information from {}.\nPlease restart SNAP.'.format(fname))
    369 return match.groupdict()

RuntimeError: cannot read version information from C:\Users\HP\AppData\Roaming\SNAP\var\log\messages.log.
Please restart SNAP.
abradley60 commented 2 months ago

Hi @nikkopante, I was facing a similar issue when installing the most recent version from git, i.e, python -m pip install git+https://github.com/johntruckenbrodt/pyroSAR.git. Note I am using SNAP version 9.0.0 on linux.

I was able to resolve the issue by downgrading to a previous version of pyroSAR. i.e. python -m pip install pyrosar==0.23.0.

This won't solve the root cause of your issue but might help you get a working process for the time being.

johntruckenbrodt commented 2 months ago

Hi @nikkopante it looks like you are not using the latest version of pyroSAR. It is trying to get the version of s1tbx, which does no longer exist with SNAP 10. I could imagine that you set up an environment with Python >=3.11 and then installed pyroSAR into it. This will install an older version of pyroSAR because version 0.25.0 introduced an upper Python version limit. See here. I hope to be able to fix this soon. Could you try again with a Python 3.10 environment?

Thanks @abradley60 for helping to solve this.

nikkopante commented 2 months ago

Hi @johntruckenbrodt, I installed Python=3.10 and managed to install pyroSAR=0.26.0. It is working now. Thank you and @abradley60 for the help.

johntruckenbrodt commented 2 months ago

Great! Happy processing @nikkopante