Could not obtain driver: OGR_GMT

After upgrading to PyGMT 13.0 … code that used to run OK now crashes out with the following:

DataSourceError: Could not obtain driver: OGR_GMT (check that it was installed correctly into GDAL)

The offending line of code is a simply (“gdf” is a Pandas geodataframe):

fig.plot(gdf)

The odd thing is that it works on a first run through, and crashed out thereafter.

Can anyone advise?

FYI, here’s a package list:

> ---------- PYTHON ----------
> 3.12.7 | packaged by conda-forge
> 
> ---------- PYGMT ----------
> PyGMT information:
>   version: v0.13.0
> System information:
>   python: 3.12.7 | packaged by conda-forge 
> 
> Dependency information:
>   numpy: 2.1.3
>   pandas: 2.2.3
>   xarray: 2024.10.0
>   netCDF4: 1.7.1
>   packaging: 24.1
>   contextily: 1.6.2
>   geopandas: 1.0.1
>   IPython: 8.29.0
>   rioxarray: 0.17.0
>   gdal: 3.9.3
>   ghostscript: 10.04.0
> GMT library information:
>   version: 6.5.0
>  
> ---------- RIOXARRAY ----------
> rioxarray (0.17.0) deps:
>   rasterio: 1.4.2
>     xarray: 2024.10.0
>       GDAL: 3.9.3
>       GEOS: 3.13.0
>       PROJ: 9.5.0
> 
> Other python deps:
>      scipy: 1.14.1
>     pyproj: 3.7.0

It’s likely related to the issue reported in geopandas 1.0.0 or pyogrio 0.9.0 doesn't support OGR_GMT output? · Issue #3301 · GenericMappingTools/pygmt · GitHub.

Maybe you can try downgrading geopandas to <1.0. Or try adding the following codes at the start of your script:

import pyogrio

pyogrio.core._register_drivers()