How to install GDAL Python Bindings for Postgres.app

389 views Asked by At

I installed the latest Postgre.app version Version 2.5.6 (139) Universal version for my new MacBook Pro M1. After setting up the CLI tools, I am able to access all gdal binaries that come bundled like gdalinfo.

However I also need to install the python bindings to use cli utilities like gdal2tiles.py. What's the right way to go about installing these so they work with the rest of gdal bundled with latest Postgress.app?

Current version bundled with Postgres.app is

➜ gdalinfo --version
GDAL 3.3.3, released 2021/10/25

Postgres.app installs GDAL binaries at:

/Applications/Postgres.app/Contents/Versions/latest/bin and currently has the following bundled:

clusterdb         ecpg              gdal_translate    gdalinfo          gdaltindex        invproj           pg_amcheck        pg_ctl            pg_resetwal       pg_verifybackup   proj              vacuumdb
createdb          gdal-config       gdal_viewshed     gdallocationinfo  gdaltransform     nearblack         pg_archivecleanup pg_dump           pg_restore        pg_waldump        psql              vacuumlo
createuser        gdal_contour      gdaladdo          gdalmanage        gdalwarp          ogr2ogr           pg_basebackup     pg_dumpall        pg_rewind         pgbench           raster2pgsql
cs2cs             gdal_create       gdalbuildvrt      gdalmdiminfo      geod              ogrinfo           pg_checksums      pg_isready        pg_test_fsync     pgsql2shp         reindexdb
dropdb            gdal_grid         gdaldem           gdalmdimtranslate initdb            ogrtindex         pg_config         pg_receivewal     pg_test_timing    postgres          shp2pgsql
dropuser          gdal_rasterize    gdalenhance       gdalsrsinfo       invgeod           oid2name          pg_controldata    pg_recvlogical    pg_upgrade        postmaster        testepsg

I realize there are plenty of ways to install gdal with python bindings using brew and pip, but I am looking to do this the right way while utilizing the core gdal that comes with Postgres.app

Any help is appreciated, Thanks!

1

There are 1 answers

0
hyperknot On

Use pygdal, it is made for this exact purpose.

export GDALHOME="/Applications/Postgres.app/Contents/Versions/latest"
pip install pygdal=="`gdal-config --version`.*"