PermissionError when export to GeoTIFF on Windows

Is there an issue when exporting eopatch to GeoTIFF on Windows machine?

This is my code:

for i in range(len(patchIDs)):
    eop_path = os.path.join(str(PATCH_FOLDER), f'eopatch_{i}')
    if os.path.exists(eop_path):
        eop = EOPatch.load(eop_path)
        export_tiff = ExportToTiff(feature=(FeatureType.DATA, 'BANDS'), folder=str(PATCH_FOLDER), config=config,
        export_tiff.execute(eop, filename=f'eopatch_{i}.tif')

But I encountered the PermissionError like the following:

PermissionError                           Traceback (most recent call last)
~\miniconda3\envs\eo-learn\lib\site-packages\fs\ in makedir(self, path, permissions, recreate)
    336             try:
--> 337                 os.mkdir(sys_path, mode)
    338             except OSError as error:

PermissionError: [WinError 5] Access is denied: b'D:\\'

During handling of the above exception, another exception occurred:

DirectoryExpected                         Traceback (most recent call last)
<ipython-input-74-9de9396c5c76> in <module>
      4         eop = EOPatch.load(eop_path)
      5         export_tiff = ExportToTiff(feature=(FeatureType.DATA, 'BANDS'), folder='./output/patches/', config=config,
----> 6         export_tiff.execute(eop, filename=f'eopatch_{i}.tif')

~\miniconda3\envs\eo-learn\lib\site-packages\eolearn\io\ in execute(self, eopatch, filename)
    308             dst_width, dst_height = width, height
--> 310         filesystem, filename_paths = self._get_filesystem_and_paths(filename, eopatch.timestamp, create_paths=True)
    312         with filesystem:

~\miniconda3\envs\eo-learn\lib\site-packages\eolearn\io\ in _get_filesystem_and_paths(self, filename, timestamps, create_paths)
     76             paths_to_create = {fs.path.dirname(filename_path) for filename_path in filename_paths}
     77             for filename_path in paths_to_create:
---> 78                 filesystem.makedirs(filename_path, recreate=True)
     80         return filesystem, filename_paths

~\miniconda3\envs\eo-learn\lib\site-packages\fs\ in makedirs(self, path, permissions, recreate)
   1074                         raise
   1075             try:
-> 1076                 self.makedir(path, permissions=permissions)
   1077             except errors.DirectoryExists:
   1078                 if not recreate:

~\miniconda3\envs\eo-learn\lib\site-packages\fs\ in makedir(self, path, permissions, recreate)
    343                 else:
    344                     raise
--> 345             return self.opendir(_path)
    347     def openbin(self, path, mode="r", buffering=-1, **options):

~\miniconda3\envs\eo-learn\lib\site-packages\fs\ in __exit__(self, exc_type, exc_value, traceback)
     88                 if getattr(exc_value, "args", None) == 32:  # pragma: no cover
     89                     fserror = errors.ResourceLocked
---> 90             reraise(fserror, fserror(self._path, exc=exc_value), traceback)

~\AppData\Roaming\Python\Python38\site-packages\ in reraise(tp, value, tb)
    700                 value = tp()
    701             if value.__traceback__ is not tb:
--> 702                 raise value.with_traceback(tb)
    703             raise value
    704         finally:

~\miniconda3\envs\eo-learn\lib\site-packages\fs\ in makedir(self, path, permissions, recreate)
    335         with convert_os_errors("makedir", path, directory=True):
    336             try:
--> 337                 os.mkdir(sys_path, mode)
    338             except OSError as error:
    339                 if error.errno == errno.ENOENT:

DirectoryExpected: path '' should be a directory

But, I didn’t find this issue when I try using Google Colab which basically uses Linux system I guess.

Hi @suhendra0812,

Thanks for reporting this issue. It seems that ExportToTiff task is not handling Windows paths correctly in some cases. We will look into the problem and fix it in the next release.

Until then I recommend running this task on Linux or Mac OS.

Thanks for the clarification