3

I'm trying to install pygdal using pip but I get a version mismatch (2.2.1 vs 2.2.0). I think python has the incorrect version. I was installing gdal but it gave me version 1.11 so I installed gdal2 from osgeo4mac which gives me the latest version, 2.2.1 but it fails to match 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
Openmic
  • 163
  • 11

2 Answers2

6

Install pydal accordingly to your GDAL version if gdal-config --version gives you 2.2.1 then

pip install pygdal==2.2.1.3

(if you don´t want to update GDAL)

if you are not focused on a certain version:

gdal_version=$(gdal-config --version); echo $gdal_version
pip install pygdal>=${gdal_version}.0,<=${gdal_version}.999
## # for zsh
#pip install pygdal">=${gdal_version}.0,<=${gdal_version}.999"
InLaw
  • 2,026
  • 2
  • 16
  • 28
1

It looks like pygdal does not yet support gdal 2.2.1. Pygdal Github shows:

Only a small set of GDAL versions is currently supported. At this point they are: 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, and 2.2.0.

You can either install an older GDAL (see Homebrew install specific version of formula?) or use GDAL without pygdal (there's also gdal2-python formula on Homebrew).

Jerr
  • 483
  • 1
  • 7
  • 14