ubarsc / python-fmask

A set of command line utilities and Python modules that implement the ‘fmask’ algorithm
https://www.pythonfmask.org
GNU General Public License v3.0
75 stars 21 forks source link

Dependencies issue. #84

Closed fekenzofugi closed 2 weeks ago

fekenzofugi commented 2 weeks ago

I've followed the download process on https://www.pythonfmask.org/en/latest/index.html#downloads. Using anaconda

conda create -n myenv python-fmask
conda activate myenv

But when i run the followed command

fmask_sentinel2Stacked -o cloud.img --safedir S2B_MSIL1C_20240822T125309_N0511_R052_T24MXV_20240822T174938.SAFE

I got this error

Traceback (most recent call last):
  File "/home/nipe/anaconda3/envs/myenv/lib/python3.12/site-packages/osgeo/__init__.py", line 30, in swig_import_helper
    return importlib.import_module(mname)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nipe/anaconda3/envs/myenv/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 921, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 813, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 1289, in create_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
ImportError: /home/nipe/anaconda3/envs/myenv/lib/python3.12/site-packages/osgeo/../../../libgdal.so.35: undefined symbol: sqlite3_total_changes64

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/nipe/anaconda3/envs/myenv/bin/fmask_sentinel2Stacked", line 7, in <module>
    from fmask.cmdline.sentinel2Stacked import mainRoutine
  File "/home/nipe/anaconda3/envs/myenv/lib/python3.12/site-packages/fmask/cmdline/sentinel2Stacked.py", line 29, in <module>
    from osgeo import gdal
  File "/home/nipe/anaconda3/envs/myenv/lib/python3.12/site-packages/osgeo/__init__.py", line 35, in <module>
    _gdal = swig_import_helper()
            ^^^^^^^^^^^^^^^^^^^^
  File "/home/nipe/anaconda3/envs/myenv/lib/python3.12/site-packages/osgeo/__init__.py", line 32, in swig_import_helper
    return importlib.import_module('_gdal')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nipe/anaconda3/envs/myenv/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named '_gdal'

But i've already installed the gdal package.

How to solve this error?

Where should the sentinel2 .SAFE folder be placed?

neilflood commented 2 weeks ago

This is not related to the .SAFE folder. It looks like something has gone wrong with the installation, and you are missing parts of the gdal package.

How did you install conda? Was it with miniconda, or with the full anaconda package? And did you configure the conda-forge channel?

If you had not configured conda-forge as the default channel, try this. Remove the myenv environment, and re-create it with this command

conda create -c conda-forge -n myenv python-fmask
fekenzofugi commented 2 weeks ago

It worked! Thank you.

But i'm receiving this error right now:

Traceback (most recent call last):
  File "/home/fekenzofugi/anaconda3/envs/myenv/bin/fmask_sentinel2Stacked", line 7, in <module>
    from fmask.cmdline.sentinel2Stacked import mainRoutine
  File "/home/fekenzofugi/Documents/python-fmask/fmask/cmdline/sentinel2Stacked.py", line 38, in <module>
    from fmask import fmask
  File "/home/fekenzofugi/Documents/python-fmask/fmask/fmask.py", line 64, in <module>
    from . import fillminima
  File "/home/fekenzofugi/Documents/python-fmask/fmask/fillminima.py", line 37, in <module>
    from . import _fillminima
ImportError: cannot import name '_fillminima' from 'fmask' (/home/fekenzofugi/Documents/python-fmask/fmask/__init__.py)
gillins commented 2 weeks ago

You appear to be pulling in fmask from your Documents directory instead of the conda install. Do you have a clone of the source in there? Can you try running from a folder without fmask source in it...

fekenzofugi commented 2 weeks ago

It worked, thank you.