嘗試運行 conda update conda 命令以後,在 spyder 中嘗試通過 from osgeo import gdal 導入 gdal,出現錯誤“ImportError: DLL load failed while importing _gdal: 找不到指定的模塊。”
from osgeo import gdalTraceback (most recent call last): File ~\anaconda3\lib\site-packages\osgeo\__init__.py:29 in swig_import_helper return importlib.import_module(mname) File ~\anaconda3\lib\importlib\__init__.py:127 in import_module return _bootstrap._gcd_import(name[level:], package, level) File
_gdal = swig_import_helper() File ~\anaconda3\lib\site-packages\osgeo\
__init__.py:
41
in swig_import_helper raise ImportError(traceback_string +
'\n' + msg)ImportError: Traceback (most recent
call last): File
"C:\Users\p676p\anaconda3\lib\site-packages\osgeo\__init__.py", line
29,
in swig_import_helper return importlib.import_module(mname) File
"C:\Users\p676p\anaconda3\lib\importlib\__init__.py", line
127,
in import_module return
_bootstrap.
_gcd_import(
name[level:], package, level) File
"
"
, line
1030,
in
_gcd_import File
"
"
, line
1007,
in
_find_and_load File
"
"
, line
986,
in
_find_and_load_unlocked File
"
"
, line
666,
in
_load_unlocked File
"
"
, line
565,
in module_from_spec File
"
"
, line
1173,
in create_module File
"
"
, line
228,
in
_call_with_frames_removedImportError: DLL
load failed
while importing
_gdal: 找不到指定的模塊。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().
不知道如何解決