我尝试使用pip安装pygdal但是我的版本不匹配(2.2.1 vs 2.2.0)。我认为python的版本不正确。我正在安装gdal,但它给了我1.11版,所以我从osgeo4mac安装了gdal2,它给了我最新的版本,2.2.1但它无法匹配v2.2.0。
pip list | grep GDAL
GDAL (2.2.1)
$ gdal-config --version
2.2.1
$ pip install pygdal
Collecting pygdal
Using cached pygdal-2.2.0.3.tar.gz
Requirement already satisfied: numpy>=1.0.0 in /usr/local/lib/python3.6/site-packages (from pygdal)
Building wheels for collected packages: pygdal
Running setup.py bdist_wheel for pygdal ... error
Complete output from command /usr/local/opt/python3/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/rc/jqv1jd_s4b73mtzpsgyj7y6w0000gp/T/pip-build-fz5kkddd/pygdal/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /var/folders/rc/jqv1jd_s4b73mtzpsgyj7y6w0000gp/T/tmp0j5fgt_7pip-wheel- --python-tag cp36:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.12-x86_64-3.6
creating build/lib.macosx-10.12-x86_64-3.6/osgeo
copying osgeo/__init__.py -> build/lib.macosx-10.12-x86_64-3.6/osgeo
copying osgeo/gdal.py -> build/lib.macosx-10.12-x86_64-3.6/osgeo
copying osgeo/gdal_array.py -> build/lib.macosx-10.12-x86_64-3.6/osgeo
copying osgeo/gdalconst.py -> build/lib.macosx-10.12-x86_64-3.6/osgeo
copying osgeo/gdalnumeric.py -> build/lib.macosx-10.12-x86_64-3.6/osgeo
copying osgeo/gnm.py -> build/lib.macosx-10.12-x86_64-3.6/osgeo
copying osgeo/ogr.py -> build/lib.macosx-10.12-x86_64-3.6/osgeo
copying osgeo/osr.py -> build/lib.macosx-10.12-x86_64-3.6/osgeo
running build_ext
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/rc/jqv1jd_s4b73mtzpsgyj7y6w0000gp/T/pip-build-fz5kkddd/pygdal/setup.py", line 173, in <module>
cmdclass=dict(build_ext=gdal_ext),
File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/local/lib/python3.6/site-packages/wheel/bdist_wheel.py", line 179, in run
self.run_command('build')
File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/private/var/folders/rc/jqv1jd_s4b73mtzpsgyj7y6w0000gp/T/pip-build-fz5kkddd/pygdal/setup.py", line 41, in run
inst_gdal_version, GDAL_VERSION))
__main__.GDALConfigError: Version mismatch 2.2.1 != 2.2.0
答案 0 :(得分:2)
根据您的GDAL版本安装pydal
如果gdal-config --version
给你2.2.1
然后
pip install pygdal==2.2.1.3
(如果您不想更新GDAL)
答案 1 :(得分:1)
看起来pygdal还不支持gdal 2.2.1。 Pygdal Github显示:
目前仅支持一小组GDAL版本。此时它们是:1.8.1,1.9.2,1.10.0,1.10.1,1.11.0,1.11.1,1.11.2,1.11.3,1.11.4,2.1.0,2.1.1, 2.1.2,2.1.3和2.2.0。
您可以安装较旧的GDAL(请参阅Homebrew install specific version of formula?)或使用不带pygdal的GDAL(在Homebrew上也有gdal2-python公式)。