Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

Error message when trying to run a code with GDAL

$
0
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_removedImportError: 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_removedImportError: 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 variableto 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 win32Type "help", "copyright", "credits" or "license" for more information.>>> from osgeo import gdalTraceback (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_removedImportError: 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_removedImportError: 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 variableto 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?


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>