0

i'm trying to solve this problem for a week now and it seems i did all i could.

this is the error message i'm getting:

Traceback (most recent call last):
  File "C:\Users\\anaconda3\envs\pygdal38\lib\site-packages\osgeo\__init__.py", line 29, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Users\\anaconda3\envs\pygdal38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 657, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 556, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 1166, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed while importing _gdal: Não foi possível encontrar o procedimento especificado.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:/Users//Desktop/Python/começando true color.py", line 8, in <module>
    from remap import remap # Import the Remap function
  File "c:\Users\\Desktop\Python\remap.py", line 6, in <module>
    from osgeo import gdal
  File "C:\Users\\anaconda3\envs\pygdal38\lib\site-packages\osgeo\__init__.py", line 45, in <module>
    _gdal = swig_import_helper()
  File "C:\Users\\anaconda3\envs\pygdal38\lib\site-packages\osgeo\__init__.py", line 41, in swig_import_helper
    raise ImportError(traceback_string + '\n' + msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\\anaconda3\envs\pygdal38\lib\site-packages\osgeo\__init__.py", line 29, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Users\\anaconda3\envs\pygdal38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 657, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 556, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 1166, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed while importing _gdal: Não foi possível encontrar o procedimento especificado.

On Windows, with Python >= 3.8, DLLs are no longer imported from the PATH.
If gdalXXX.dll is in the PATH, then set the USE_PATH_FOR_GDAL_PYTHON=YES environment variable
to feed the PATH into os.add_dll_directory().

at first i thought it could be a problem with GDAL, so i uninstalled through conda and reinstalled but didn't work. So i went in the anaconda cmd and opened python shell in it

when i tried to import GDAL it showed the same thing

Python 3.9.12 (main, Apr  4 2022, 05:22:27) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from osgeo import gdal
Traceback (most recent call last):
  File "C:\Users\\anaconda3\lib\site-packages\osgeo\__init__.py", line 29, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Users\\anaconda3\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 565, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 1173, in create_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
ImportError: DLL load failed while importing _gdal: Não foi possível encontrar o módulo especificado.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\ire0052\anaconda3\lib\site-packages\osgeo\__init__.py", line 45, in <module>
    _gdal = swig_import_helper()
  File "C:\Users\ire0052\anaconda3\lib\site-packages\osgeo\__init__.py", line 41, in swig_import_helper
    raise ImportError(traceback_string + '\n' + msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\ire0052\anaconda3\lib\site-packages\osgeo\__init__.py", line 29, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Users\ire0052\anaconda3\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 565, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 1173, in create_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
ImportError: DLL load failed while importing _gdal: Não foi possível encontrar o módulo especificado.

On Windows, with Python >= 3.8, DLLs are no longer imported from the PATH.
If gdalXXX.dll is in the PATH, then set the USE_PATH_FOR_GDAL_PYTHON=YES environment variable
to feed the PATH into os.add_dll_directory().

What almost helped was creating a new environment for GDAL with a downgraded python version (3.8.13). This is how it went:

>>> from osgeo import gdal
>>>

no error message. But when running the code i want in VS CODE it appears again... Does anyone have a way to solve this?

Daniel_
  • 1
  • 1
  • Is your operating system Windows? It's difficult or impossible to run gdal on Windows, I tried my best and ended up using Linux or Mac. – Hossein Asadi Jul 12 '22 at 12:51
  • yeah, i'm using windows at the moment. maybe i should really try to dual-boot my work pc so i can use it, but i kept my hopes of getting rid of this message as the gdal/ matplot tutorial i'm following uses windows and it was working flawlessly – Daniel_ Jul 12 '22 at 13:03
  • Do you have any libraries installed that use the same binaries? That's often behind DLL issues like this. And did you try what the error suggests? Setting `os.environ["USE_PATH_FOR_GDAL_PYTHON"] = "YES"`` before importing `gdal`. – Rutger Kassies Jul 21 '22 at 07:11

0 Answers0