我使用的是32位Windows操作系统,Python版本为3.6,尝试按照这个教程安装GDAL包,但没有成功。后来尝试使用pip安装,仍然出现错误。
from osgeo import gdal
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
from osgeo import gdal
File "C:\Users\username\AppData\Local\Programs\Python\Python36-32\lib\site-packages\osgeo\__init__.py", line 41, in <module>
_gdal = swig_import_helper()
File "C:\Users\username\AppData\Local\Programs\Python\Python36-32\lib\site-packages\osgeo\__init__.py", line 37, in swig_import_helper
_mod = imp.load_module('_gdal', fp, pathname, description)
File "C:\Users\username\AppData\Local\Programs\Python\Python36-32\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\username\AppData\Local\Programs\Python\Python36-32\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: The specified module could not be found.
通过PIP安装GDAL:
pip install GDAL
错误信息:
6\osgeo\gdal_array.py build\lib.win32-3.6\osgeo\gnm.py build\lib.win32-3.6\osgeo
\ogr.py build\lib.win32-3.6\osgeo\osr.py build\lib.win32-3.6\osgeo\__init__.py
Skipping optional fixer: ws_comma
Fixing build\lib.win32-3.6\gdal.py build\lib.win32-3.6\ogr.py build\lib.win3
2-3.6\osr.py build\lib.win32-3.6\gdalconst.py build\lib.win32-3.6\gnm.py build\l
ib.win32-3.6\gdalnumeric.py build\lib.win32-3.6\osgeo\gdal.py build\lib.win32-3.
6\osgeo\gdalconst.py build\lib.win32-3.6\osgeo\gdalnumeric.py build\lib.win32-3.
6\osgeo\gdal_array.py build\lib.win32-3.6\osgeo\gnm.py build\lib.win32-3.6\osgeo
\ogr.py build\lib.win32-3.6\osgeo\osr.py build\lib.win32-3.6\osgeo\__init__.py
Skipping optional fixer: ws_comma
running build_ext
building 'osgeo._gdal' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual
C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
----------------------------------------
Command "c:\users\username\appdata\local\programs\python\python36-32\python.exe -u
-c "import setuptools, tokenize;__file__='C:\\Users\\username\\AppData\\Local\\Temp
\\pip-install-t7el4b6x\\GDAL\\setup.py';f=getattr(tokenize, 'open', open)(__file
__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, '
exec'))" install --record C:\Users\username\AppData\Local\Temp\pip-record-r_yx0388\
install-record.txt --single-version-externally-managed --compile" failed with er
这是 Python 3.6 的一个 bug 吗?我不想使用 conda 的方式。谢谢。