EOA-team / eodal

Earth Observation Data Analysis Library
https://eodal.readthedocs.io/en/latest/
GNU General Public License v3.0
93 stars 15 forks source link

Error when importing Sentinel2 class on Windows #18

Closed gperich closed 2 years ago

gperich commented 2 years ago

Upon importing the Sentinel2 class from eodal.core.sensors import Sentinel2 on my Windows machine, i get the following error message: File "C:\Users\gperich\python_venvs\eodal\lib\site-packages\eodal\core\utils\geometry.py", line 129, in <module> def multi_to_single_points(point_features: gpd.GeoDataFrame | Path) -> gpd.GeoDataFrame: TypeError: unsupported operand type(s) for |: 'type' and 'type'

The error traces back to the multi_to_single_points function in the geometry.py file in the core\utils folder. I suspect Windows doesn't like the | operation? Or is it a python issue? I am on Python 3.9.7

lukasValentin commented 2 years ago

Hi @gperich,

this is unfortunately an issue of missing backwards compatibility (regarding the Python version). The | operator was introduced in Python 3.10 instead of the Union operator (from typing import Union). This means in Python 3.9

def add(a: Union[int, float], b: Union[int, float]):

becomes in Python 3.10

def add(a: int | float, b: int | float):

Unfortunately, back-ward compatibility is not part of Python's development philosophy.

Therefore, the only solution would be to upgrade Python to 3.10+. Sorry for that :disappointed:

gperich commented 2 years ago

oh no! I feared that this might be the cause. Well then, time to install GDAL and all the good stuff again for 3.10...