Gshhg_version:cannot open file - but the file is there

I don’t seem to be able to get my pygmt (in Jupyter Notebook) to use my gshhg files. I’ve written a test script to try to figure out what’s going on. The script is simple:

import pygmt
fig=pygmt.Figure()
fig.coast(
    region="-85/-75/3/10",
    projection="M15c",
    land="lightgray",
    water="white",
    borders="1/0.5p",
    shorelines="1/0.5p",
    frame="ag",)
fig.show()

The error message I get is:

gshhg_version: cannot open file "/opt/homebrew/Cellar/gmt/6.5.0/share/gmt/coast/binned_GSHHS_h.nc" (-101).
coast [NOTICE]: Downloading binned_GSHHS_h.nc for the first time - be patient
gshhg_version: cannot open file "/Users/lwagner/.gmt/geography/gshhg/binned_GSHHS_h.nc" (-101).
coast [WARNING]: GSHHG version 2.2.0 or newer is needed to use coastlines with GMT.
	Get and install GSHHG from ftp://ftp.soest.hawaii.edu/gshhg/.
coast [ERROR]: Could not find file [GSHHG high resolution shorelines]
gshhg_version: cannot open file "/opt/homebrew/Cellar/gmt/6.5.0/share/gmt/coast/binned_border_h.nc" (-101).
coast [NOTICE]: Downloading binned_border_h.nc for the first time - be patient
coast [ERROR]: Could not find file [GSHHG high resolution political boundaries]gshhg_version: cannot open file "/Users/lwagner/.gmt/geography/gshhg/binned_border_h.nc" (-101).

coast [ERROR]: No GSHHG databases available - must abort

Here’s the thing, though: I have those files!

(base) /opt/homebrew/Cellar/gmt/6.5.0/share/gmt/coast >ls
COPYING.LESSERv3	binned_GSHHS_i.nc	binned_river_c.nc
COPYINGv3		binned_GSHHS_l.nc	binned_river_f.nc
LICENSE.TXT		binned_border_c.nc	binned_river_h.nc
README.TXT		binned_border_f.nc	binned_river_i.nc
binned_GSHHS_c.nc	binned_border_h.nc	binned_river_l.nc
binned_GSHHS_f.nc	binned_border_i.nc
binned_GSHHS_h.nc	binned_border_l.nc

Or, with more detail:

(base) /opt/homebrew/Cellar/gmt/6.5.0/share/gmt/coast >ls -al
total 112832
drwxr-xr-x  21 lwagner  admin       672 May 22 11:26 .
drwxr-xr-x  13 lwagner  admin       416 Jan  7 04:34 ..
-rw-r--r--   1 lwagner  admin      7651 Jan  7 04:34 COPYING.LESSERv3
-rw-r--r--   1 lwagner  admin     35147 Jan  7 04:34 COPYINGv3
-rw-r--r--   1 lwagner  admin      1352 Jan  7 04:34 LICENSE.TXT
-rw-r--r--   1 lwagner  admin     15063 Jan  7 04:34 README.TXT
-rw-r--r--   1 lwagner  admin    136598 Jan  7 04:34 binned_GSHHS_c.nc
-rw-r--r--   1 lwagner  admin  31935651 Jan  7 04:34 binned_GSHHS_f.nc
-rw-r--r--   1 lwagner  admin   8437674 Jan  7 04:34 binned_GSHHS_h.nc
-rw-r--r--   1 lwagner  admin   2206533 Jan  7 04:34 binned_GSHHS_i.nc
-rw-r--r--   1 lwagner  admin    550248 Jan  7 04:34 binned_GSHHS_l.nc
-rw-r--r--   1 lwagner  admin     60813 Jan  7 04:34 binned_border_c.nc
-rw-r--r--   1 lwagner  admin   2131261 Jan  7 04:34 binned_border_f.nc
-rw-r--r--   1 lwagner  admin    509728 Jan  7 04:34 binned_border_h.nc
-rw-r--r--   1 lwagner  admin    217433 Jan  7 04:34 binned_border_i.nc
-rw-r--r--   1 lwagner  admin     98738 Jan  7 04:34 binned_border_l.nc
-rw-r--r--   1 lwagner  admin    229095 Jan  7 04:34 binned_river_c.nc
-rw-r--r--   1 lwagner  admin   7619434 Jan  7 04:34 binned_river_f.nc
-rw-r--r--   1 lwagner  admin   2266940 Jan  7 04:34 binned_river_h.nc
-rw-r--r--   1 lwagner  admin    908481 Jan  7 04:34 binned_river_i.nc
-rw-r--r--   1 lwagner  admin    364773 Jan  7 04:34 binned_river_l.nc

The README.TXT starts with the following:

$LastChangedDate: 2017-06-14 17:11:54 -1000 (Wed, 14 Jun 2017) $
$Revision: 679 $

Note: If you are adding the gshhg-gmt-x.x.x BEFORE you install GMT
then make sure to set the GSHHG_PATH setting in cmake/ConfigUser.cmake
before building GMT. If you are adding gshhg-gmt-x.x.x AFTER installing
GMT then you need to specify its path via gmt.conf's DIR_GSHHG setting.

--------------------------------------------------------------------
Global Self-consistent Hierarchical High-resolution Geography, GSHHG

                Version 2.3.7 June 15, 2017
         Distributed under the Lesser GNU Public License

Updates the Northern Mariana Islands with CUPS data from NOAA, adds
two missing islands to northern Norway, and adds in the missing
Kosovo-Serbia boundary.

Earlier GSHHG Version-specific comments:
====================================================================
Version 2.3.6 August 19, 2016

Fixed 11 crossings in Antarctica grounding line and one in the ice front.
Added missing islands Georgetown and MacMahan, ME, and updated Jan Mayen, Norway
[thanks to Norwegian Polar Institute]

[...]

Any ideas? I’m on an M2 Mac, if that makes a difference. Now that I think about it, I’m not sure I’ve seen this work since I switched over…

Hello @SeismoMapper,

thanks for this detailed report!

Can you please post the output of
python -c "import pygmt; pygmt.show_versions()" (in a terminal) or pygmt.show_versions() (directly in Jupyter notebook).

(research) /Users/lwagner >python -c "import pygmt; pygmt.show_versions()"
PyGMT information:
  version: v0.12.0
System information:
  python: 3.10.13 | packaged by conda-forge | (main, Dec 23 2023, 15:35:25) [Clang 16.0.6 ]
  executable: /Users/lwagner/anaconda3/envs/research/bin/python
  machine: macOS-14.3.1-arm64-arm-64bit
Dependency information:
  numpy: 1.26.4
  pandas: 2.2.0
  xarray: 2024.5.0
  netCDF4: 1.6.5
  packaging: 23.2
  contextily: None
  geopandas: None
  ipython: None
  rioxarray: None
  ghostscript: 10.02.1
GMT library information:
  binary version: 6.5.0
  cores: 11
  grid layout: rows
  image layout: 
  library path: /opt/homebrew/Cellar/gmt/6.5.0/lib/libgmt.dylib
  padding: 2
  plugin dir: /opt/homebrew/Cellar/gmt/6.5.0/lib/gmt/plugins
  share dir: /opt/homebrew/Cellar/gmt/6.5.0/share/gmt
  version: 6.5.0

Does GMT CLI works for you?

gmt coast -Rg -JH15c -W1p -pdf map

yes.
map.pdf (54.2 KB)

The -101 error code means some errors at HDF5 layer (xref: NetCDF: netcdf.h File Reference). Maybe your GSHHG data files are corrupted?

You can try to download the GSHHG data files manually and place them in /Users/lwagner/.gmt/geography/gshhg/.

They already exist there also (see below). I’ll download and replace to see if that helps.
(base) /Users/lwagner/.gmt/geography/gshhg >ls -al
total 84992
drwx------ 9 lwagner staff 288 May 22 11:38 .
drwx------ 3 lwagner staff 96 Mar 14 11:38 …
-rw-r–r-- 1 lwagner staff 136598 Mar 14 11:38 binned_GSHHS_c.nc
-rw-r–r-- 1 lwagner staff 31935651 May 22 11:34 binned_GSHHS_f.nc
-rw-r–r-- 1 lwagner staff 8437674 May 22 11:38 binned_GSHHS_h.nc
-rw-r–r-- 1 lwagner staff 2206533 May 22 11:17 binned_GSHHS_i.nc
-rw-r–r-- 1 lwagner staff 60813 Mar 14 11:38 binned_border_c.nc
-rw-r–r-- 1 lwagner staff 509728 May 22 11:38 binned_border_h.nc
-rw-r–r-- 1 lwagner staff 217433 May 22 11:17 binned_border_i.nc

Sadly, no, that didn’t help, either. exact same error as before.
Thanks to all of you for your help - I hope we can figure this out!

Please run gmt coast -Rg -JH15c -W1p -Vd -pdf map and post the full debugging messages.

Sure! Here it is
(research) /Users/lwagner/.gmt/geography/gshhg >gmt coast -Rg -JH15c -W1p -Vd -pdf
gmt [DEBUG]: GMT_Create_Session: Terminal width = 99
gmt [DEBUG]: Obtained the ppid from parent: 56965
gmt [DEBUG]: Enter: gmtinit_new_GMT_ctrl
gmt [DEBUG]: GMT->session.SHAREDIR = /opt/homebrew/Cellar/gmt/6.5.0/share/gmt
gmt [DEBUG]: GMT->session.HOMEDIR = /Users/lwagner
gmt [DEBUG]: GMT->session.USERDIR = /Users/lwagner/.gmt [created]
gmt [DEBUG]: GMT->session.CACHEDIR = /Users/lwagner/.gmt/cache [created]
gmt [DEBUG]: GMT: 0. Will try to find subdir=postscriptlight stem = PSL_custom_fonts suffix=.txt
gmt [DEBUG]: GMT: 1. gmt_getsharepath trying current dir
gmt [DEBUG]: GMT: 2. gmt_getsharepath trying USERDIR /Users/lwagner/.gmt
gmt [DEBUG]: GMT: 3. gmt_getsharepath trying USERDIR subdir /Users/lwagner/.gmt/postscriptlight
gmt [DEBUG]: GMT: 4. gmt_getsharepath trying SHAREDIR subdir /opt/homebrew/Cellar/gmt/6.5.0/share/gmt/postscriptlight
gmt [DEBUG]: GMT: 5. gmt_getsharepath trying SHAREDIR /opt/homebrew/Cellar/gmt/6.5.0/share/gmt
gmt [DEBUG]: GMT: 6. gmt_getsharepath failed
gmt [DEBUG]: Map distance calculation will be Cartesian
gmt [DEBUG]: Exit: gmtinit_new_GMT_ctrl
gmt [DEBUG]: Enter: New_PSL_Ctrl
gmt [DEBUG]: Exit: New_PSL_Ctrl
gmt [DEBUG]: Enter: gmt_manage_workflow
gmt [DEBUG]: Exit : gmt_manage_workflow
gmt [DEBUG]: Enter: PSL_beginsession
gmt [DEBUG]: Exit : PSL_beginsession
gmt [DEBUG]: Enter: PSL_setdefaults
gmt [DEBUG]: Exit : PSL_setdefaults
gmt [DEBUG]: Enter: gmtlib_io_init
gmt [DEBUG]: Exit : gmtlib_io_init
gmt [DEBUG]: Enter: gmt_hash_init
gmt [DEBUG]: Exit: gmt_hash_init
gmt [DEBUG]: Enter: gmt_hash_init
gmt [DEBUG]: Exit: gmt_hash_init
gmt [DEBUG]: Enter: gmt_reload_settings
gmt [DEBUG]: The PROJ_GEODESIC set to Vincenty
gmt [DEBUG]: Look for file /Users/lwagner/gmt.conf
gmt [DEBUG]: Look for file /Users/lwagner/.gmt/gmt.conf
gmt [DEBUG]: Look for file /Users/lwagner/.gmt/server/gmt.conf
gmt [DEBUG]: Look for file /Users/lwagner/.gmt/cache/gmt.conf
gmt [DEBUG]: Could not find file gmt.conf
gmt [DEBUG]: Exit: gmt_reload_settings
gmt [DEBUG]: Enter: gmtlib_plot_C_format
gmt [DEBUG]: Exit: gmtlib_plot_C_format
gmt [DEBUG]: Enter: gmtinit_get_history
gmt [DEBUG]: Initialize FFTW with 11 threads.
gmt [DEBUG]: GMT_Create_Session initialized GMT structure
gmt [DEBUG]: Loading core GMT shared library: libgmt.dylib
gmt [DEBUG]: Shared Library # 0 (core). Path = libgmt.dylib
gmt [DEBUG]: Loading GMT plugins from: /opt/homebrew/Cellar/gmt/6.5.0/lib/gmt/plugins
gmt [DEBUG]: Shared Library # 1 (supplements). Path = /opt/homebrew/Cellar/gmt/6.5.0/lib/gmt/plugins/supplements.so
gmt [ERROR]: Shared GMT module not found: coast

ERROR: No module named coast was found. This could mean one of four cases:

  1. There actually is no such module; please check your spelling.
  2. You used a modern mode module name while running in GMT classic mode.
  3. Module exists in the GMT supplemental library, but the library could not be found.
  4. Module exists in a GMT custom library, but none was specified via GMT_CUSTOM_LIBS.
    Shared libraries must be in standard system paths or set via environmental parameter DYLD_LIBRARY_PATH.

gmt [DEBUG]: Entering GMT_Destroy_Session

Sorry - before I didn’t put the pdf file name in after “pdf”. Here’s the version with it.
(research) /Users/lwagner >gmt coast -Rg -JH15c -W1p -Vd -pdf map
gmt [DEBUG]: GMT_Create_Session: Terminal width = 189
gmt [DEBUG]: Obtained the ppid from parent: 56965
gmt [DEBUG]: Enter: gmtinit_new_GMT_ctrl
gmt [DEBUG]: GMT->session.SHAREDIR = /opt/homebrew/Cellar/gmt/6.5.0/share/gmt
gmt [DEBUG]: GMT->session.HOMEDIR = /Users/lwagner
gmt [DEBUG]: GMT->session.USERDIR = /Users/lwagner/.gmt [created]
gmt [DEBUG]: GMT->session.CACHEDIR = /Users/lwagner/.gmt/cache [created]
gmt [DEBUG]: GMT: 0. Will try to find subdir=postscriptlight stem = PSL_custom_fonts suffix=.txt
gmt [DEBUG]: GMT: 1. gmt_getsharepath trying current dir
gmt [DEBUG]: GMT: 2. gmt_getsharepath trying USERDIR /Users/lwagner/.gmt
gmt [DEBUG]: GMT: 3. gmt_getsharepath trying USERDIR subdir /Users/lwagner/.gmt/postscriptlight
gmt [DEBUG]: GMT: 4. gmt_getsharepath trying SHAREDIR subdir /opt/homebrew/Cellar/gmt/6.5.0/share/gmt/postscriptlight
gmt [DEBUG]: GMT: 5. gmt_getsharepath trying SHAREDIR /opt/homebrew/Cellar/gmt/6.5.0/share/gmt
gmt [DEBUG]: GMT: 6. gmt_getsharepath failed
gmt [DEBUG]: Map distance calculation will be Cartesian
gmt [DEBUG]: Exit: gmtinit_new_GMT_ctrl
gmt [DEBUG]: Enter: New_PSL_Ctrl
gmt [DEBUG]: Exit: New_PSL_Ctrl
gmt [DEBUG]: Enter: gmt_manage_workflow
gmt [DEBUG]: Exit : gmt_manage_workflow
gmt [DEBUG]: Enter: PSL_beginsession
gmt [DEBUG]: Exit : PSL_beginsession
gmt [DEBUG]: Enter: PSL_setdefaults
gmt [DEBUG]: Exit : PSL_setdefaults
gmt [DEBUG]: Enter: gmtlib_io_init
gmt [DEBUG]: Exit : gmtlib_io_init
gmt [DEBUG]: Enter: gmt_hash_init
gmt [DEBUG]: Exit: gmt_hash_init
gmt [DEBUG]: Enter: gmt_hash_init
gmt [DEBUG]: Exit: gmt_hash_init
gmt [DEBUG]: Enter: gmt_reload_settings
gmt [DEBUG]: The PROJ_GEODESIC set to Vincenty
gmt [DEBUG]: Look for file /Users/lwagner/gmt.conf
gmt [DEBUG]: Look for file /Users/lwagner/.gmt/gmt.conf
gmt [DEBUG]: Look for file /Users/lwagner/.gmt/server/gmt.conf
gmt [DEBUG]: Look for file /Users/lwagner/.gmt/cache/gmt.conf
gmt [DEBUG]: Could not find file gmt.conf
gmt [DEBUG]: Exit: gmt_reload_settings
gmt [DEBUG]: Enter: gmtlib_plot_C_format
gmt [DEBUG]: Exit: gmtlib_plot_C_format
gmt [DEBUG]: Enter: gmtinit_get_history
gmt [DEBUG]: Initialize FFTW with 11 threads.
gmt [DEBUG]: GMT_Create_Session initialized GMT structure
gmt [DEBUG]: Loading core GMT shared library: libgmt.dylib
gmt [DEBUG]: Shared Library # 0 (core). Path = libgmt.dylib
gmt [DEBUG]: Loading GMT plugins from: /opt/homebrew/Cellar/gmt/6.5.0/lib/gmt/plugins
gmt [DEBUG]: Shared Library # 1 (supplements). Path = /opt/homebrew/Cellar/gmt/6.5.0/lib/gmt/plugins/supplements.so
gmt [DEBUG]: Revised options: map pdf
begin [INFORMATION]: Creating a workflow directory /Users/lwagner/.gmt/sessions/gmt_session.56965
begin [DEBUG]: The PROJ_GEODESIC set to Vincenty
begin [DEBUG]: Look for file /Users/lwagner/gmt.conf
begin [DEBUG]: Look for file /Users/lwagner/.gmt/gmt.conf
begin [DEBUG]: Look for file /Users/lwagner/.gmt/server/gmt.conf
begin [DEBUG]: Look for file /Users/lwagner/.gmt/cache/gmt.conf
begin [DEBUG]: Could not find file gmt.conf
begin [DEBUG]: Set session name to be map pdf
begin [DEBUG]: Begin Workflow. Session ID = 56965. Directory /Users/lwagner/.gmt/sessions/gmt_session.56965 created.
begin [DEBUG]: GMT now running in modern mode [Session ID = 56965]
gmt [DEBUG]: Use PS filename /Users/lwagner/.gmt/sessions/gmt_session.56965/gmt_0.ps-
gmt [DEBUG]: gmtinit_get_current_panel: No current panel selected so not in subplot mode
gmt [DEBUG]: Revised options: -Rg -JH15c -W1p -Vd
coast [DEBUG]: History: Process -Rg
coast [DEBUG]: History: Process -JH15c
coast [DEBUG]: Map distance calculation will be using great circle approximation with authalic auxiliary latitudes and authalic (R_2) radius = 6371007.1809 m, in meter.
coast [DEBUG]: Map distance calculation will be using great circle approximation with authalic auxiliary latitudes and authalic (R_2) radius = 6371007.1809 m, in meter.
coast [DEBUG]: Reset MAP_ANNOT_OBLIQUE to anywhere
coast [INFORMATION]: Central meridian not given, default to 180
coast [DEBUG]: Projected values in meters: -1.80199e+07 1.80199e+07 -9.00996e+06 9.00996e+06
coast [DEBUG]: Computed automatic parameters using dimension scaling: 0.908088
coast [INFORMATION]: Map scale is 2402.66 km per cm or 1:2.40266e+08.
coast [INFORMATION]: -D option: Selected resolution -Dc
coast [DEBUG]: 1. GSHHG: GSHHGDIR set, trying /tmp/gmt-20240107-14473-f7ivwu/gmt-6.5.0/gshhg/binned_GSHHS_c.nc
coast [DEBUG]: 1. GSHHG: Failure, could not access /tmp/gmt-20240107-14473-f7ivwu/gmt-6.5.0/gshhg/binned_GSHHS_c.nc
coast [DEBUG]: GMT: 0. Will try to find subdir=conf stem = coastline suffix=.conf
coast [DEBUG]: GMT: 1. gmt_getsharepath trying current dir
coast [DEBUG]: GMT: 2. gmt_getsharepath trying USERDIR /Users/lwagner/.gmt
coast [DEBUG]: GMT: 3. gmt_getsharepath trying USERDIR subdir /Users/lwagner/.gmt/conf
coast [DEBUG]: GMT: 4. gmt_getsharepath trying SHAREDIR subdir /opt/homebrew/Cellar/gmt/6.5.0/share/gmt/conf
coast [DEBUG]: GMT: 5. gmt_getsharepath trying SHAREDIR /opt/homebrew/Cellar/gmt/6.5.0/share/gmt
coast [DEBUG]: GMT: 6. gmt_getsharepath failed
coast [DEBUG]: GMT: 0. Will try to find subdir=coast stem = coastline suffix=.conf
coast [DEBUG]: GMT: 1. gmt_getsharepath trying current dir
coast [DEBUG]: GMT: 2. gmt_getsharepath trying USERDIR /Users/lwagner/.gmt
coast [DEBUG]: GMT: 3. gmt_getsharepath trying USERDIR subdir /Users/lwagner/.gmt/coast
coast [DEBUG]: GMT: 4. gmt_getsharepath trying SHAREDIR subdir /opt/homebrew/Cellar/gmt/6.5.0/share/gmt/coast
coast [DEBUG]: GMT: 5. gmt_getsharepath trying SHAREDIR /opt/homebrew/Cellar/gmt/6.5.0/share/gmt
coast [DEBUG]: GMT: 6. gmt_getsharepath failed
coast [DEBUG]: 3. GSHHG: Trying via sharepath
coast [DEBUG]: GMT: 0. Will try to find subdir=coast stem = binned_GSHHS_c suffix=.nc
coast [DEBUG]: GMT: 1. gmt_getsharepath trying current dir
coast [DEBUG]: GMT: 2. gmt_getsharepath trying USERDIR /Users/lwagner/.gmt
coast [DEBUG]: GMT: 3. gmt_getsharepath trying USERDIR subdir /Users/lwagner/.gmt/coast
coast [DEBUG]: GMT: 4. gmt_getsharepath trying SHAREDIR subdir /opt/homebrew/Cellar/gmt/6.5.0/share/gmt/coast
coast [DEBUG]: 3. GSHHG: Trying /opt/homebrew/Cellar/gmt/6.5.0/share/gmt/coast/binned_GSHHS_c.nc
coast [DEBUG]: 3. GSHHG: OK, could access /opt/homebrew/Cellar/gmt/6.5.0/share/gmt/coast/binned_GSHHS_c.nc
coast [DEBUG]: Calling nc_open on /opt/homebrew/Cellar/gmt/6.5.0/share/gmt/coast/binned_GSHHS_c.nc, ncid = 65536, err = 0
coast [DEBUG]: NetCDF Library Version: 4.9.2 of Mar 14 2023 20:34:25 $
coast [DEBUG]: GSHHG with two Antarcticas, read in extra ANT flgs.
coast [INFORMATION]: Selected ice front line as Antarctica coastline
coast [INFORMATION]: GSHHG version 2.3.7
coast [INFORMATION]: Derived from World Vector Shoreline, CIA WDB-II, and Atlas of the Cryosphere
coast [INFORMATION]: Processed by Paul Wessel and Walter H. F. Smith, 1994-2017
coast [DEBUG]: Running in PS mode modern
coast [DEBUG]: Use PS filename /Users/lwagner/.gmt/sessions/gmt_session.56965/gmt_0.ps-
coast [DEBUG]: Create hidden PS file /Users/lwagner/.gmt/sessions/gmt_session.56965/gmt_0.ps-
coast [DEBUG]: No figure file /Users/lwagner/.gmt/sessions/gmt_session.56965/gmt.figures - nothing to do
coast [DEBUG]: Got session name as map and default graphics formats as pdf
coast [DEBUG]: Basemap order: Frame = above Grid = above Tick/Annot = below
coast [DEBUG]: Working on bin # 161
coast [DEBUG]: Calling nc_close on ncid 65536, err = 0
coast [DEBUG]: Current size of half-baked PS file /Users/lwagner/.gmt/sessions/gmt_session.56965/gmt_0.ps- = 119374.
coast [DEBUG]: gmtlib_get_graphics_item: Fig: 0 Subplot: 2 Panel: () Inset: 0
coast [DEBUG]: No current cpt file found
coast [DEBUG]: GMT now running in modern mode [Session ID = 56965]
coast [DEBUG]: Revised options: show
end [DEBUG]: End Workflow. Session ID = 56965. Directory /Users/lwagner/.gmt/sessions/gmt_session.56965 removed.
end [DEBUG]: No figure file /Users/lwagner/.gmt/sessions/gmt_session.56965/gmt.figures - nothing to do
end [DEBUG]: No figure file /Users/lwagner/.gmt/sessions/gmt_session.56965/gmt.figures - nothing to do
end [DEBUG]: Got session name as map and default graphics formats as pdf
end [INFORMATION]: Process GMT figure queue: 1 figures found
end [INFORMATION]: Processing GMT figure #0 [map pdf ]
end [DEBUG]: gmtlib_get_graphics_item: Fig: 0 Subplot: 2 Panel: () Inset: 0
end [DEBUG]: psconvert: ‘/Users/lwagner/.gmt/sessions/gmt_session.56965/gmt_0.ps-’ -Tf -Fmap -A
end [DEBUG]: GMT now running in modern mode [Session ID = 56965]
end [DEBUG]: Revised options: ‘/Users/lwagner/.gmt/sessions/gmt_session.56965/gmt_0.ps-’ -Tf -Fmap -A
psconvert [DEBUG]: Ghostscript executable full name:
psconvert [DEBUG]: gmt_run_process_get_first_line: Pass to popen: [gs --version 2> /dev/null]
psconvert [DEBUG]: gs --version 2> /dev/null was successful
psconvert [DEBUG]: Ghostscript version: 10.02.1
psconvert [DEBUG]: Complete partial PS file /Users/lwagner/.gmt/sessions/gmt_session.56965/gmt_0.ps-
psconvert [DEBUG]: Size of half-baked PS file = 119374.
psconvert [DEBUG]: Fattened up PS file /Users/lwagner/.gmt/sessions/gmt_session.56965/gmt_0.ps-
psconvert [INFORMATION]: Processing /Users/lwagner/.gmt/sessions/gmt_session.56965/gmt_0.ps-…
psconvert [INFORMATION]: Find HiResBoundingBox …
psconvert [DEBUG]: Running: gs -q -dNOSAFER -dNOPAUSE -dBATCH -sDEVICE=bbox -DPSL_no_pagefill -dMaxBitmap=2147483647 -dUseFastColor=true ‘/Users/lwagner/.gmt/sessions/gmt_session.56965/gmt_0.ps-’ 2> ‘/Users/lwagner/.gmt/sessions/gmt_session.56965/psconvert_95442c.bb’
psconvert [INFORMATION]: Figure dimensions: Width: 423.234 points [14.9308 cm] Height: 206.352 points [7.27964 cm]
psconvert [DEBUG]: Delete /Users/lwagner/.gmt/sessions/gmt_session.56965/psconvert_95442c.bb
psconvert [INFORMATION]: [2881.04 2884.84 3304.28 3091.19]…
psconvert [INFORMATION]: Convert to PDF…
psconvert [DEBUG]: Running: gs -q -dNOPAUSE -dBATCH -dNOSAFER -dPDFSETTINGS=/prepress -dDownsampleColorImages=false -dDownsampleGrayImages=false -dDownsampleMonoImages=false -dUseFlateCompression=true -dEmbedAllFonts=true -dSubsetFonts=true -dMonoImageFilter=/FlateEncode -dAutoFilterGrayImages=false -dGrayImageFilter=/FlateEncode -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -dSCANCONVERTERTYPE=2 -dALLOWPSTRANSPARENCY -dMaxBitmap=2147483647 -dUseFastColor=true -sDEVICE=pdfwrite -g4233x2064 -r720 -sOutputFile=‘map.pdf’ ‘/Users/lwagner/.gmt/sessions/gmt_session.56965/psconvert_95442d.eps’
psconvert [DEBUG]: Delete /Users/lwagner/.gmt/sessions/gmt_session.56965/psconvert_95442d.eps
psconvert [DEBUG]: Final input buffer length was 256
end [DEBUG]: GMT now running in modern mode [Session ID = 56965]
end [DEBUG]: Revised options: map.pdf
docs [DEBUG]: Opening local file(s) via open map.pdf
end [INFORMATION]: Destroying the current workflow directory /Users/lwagner/.gmt/sessions/gmt_session.56965
end [DEBUG]: Delete gmt.canvas.0
end [DEBUG]: Delete gmt.conf
end [DEBUG]: Delete gmt.layers.0
end [DEBUG]: Delete gmt.session
end [DEBUG]: Delete gmt_0.ps-
gmt [DEBUG]: Entering GMT_Destroy_Session
gmt [DEBUG]: gmtlib_get_graphics_item: Fig: 0 Subplot: 2 Panel: () Inset: 0

coast [DEBUG]: 3. GSHHG: Trying /opt/homebrew/Cellar/gmt/6.5.0/share/gmt/coast/binned_GSHHS_c.nc
coast [DEBUG]: 3. GSHHG: OK, could access /opt/homebrew/Cellar/gmt/6.5.0/share/gmt/coast/binned_GSHHS_c.nc
coast [DEBUG]: Calling nc_open on /opt/homebrew/Cellar/gmt/6.5.0/share/gmt/coast/binned_GSHHS_c.nc, ncid = 65536, err = 0

So at least, the binned_GSHHG_c.nc file is found and is correct.

What happens if you run:

import pygmt
fig = pygmt.Figure()
fig.coast(region="g", projection="H15c", shorelines="1p", verbose="d")
fig.show()

pygmt-session [DEBUG]: Use PS filename /Users/lwagner/.gmt/sessions/gmt_session.60263/gmt_1.ps-
pygmt-session [DEBUG]: gmtinit_get_current_panel: No current panel selected so not in subplot mode
pygmt-session [DEBUG]: Revised options: -JH15c -Rg -Vd -W1p
coast [DEBUG]: History: Process -JH15c
coast [DEBUG]: History: Process -Rg
coast [DEBUG]: Map distance calculation will be using great circle approximation with authalic auxiliary latitudes and authalic (R_2) radius = 6371007.1809 m, in meter.
coast [DEBUG]: Map distance calculation will be using great circle approximation with authalic auxiliary latitudes and authalic (R_2) radius = 6371007.1809 m, in meter.
coast [DEBUG]: Reset MAP_ANNOT_OBLIQUE to anywhere
coast [INFORMATION]: Central meridian not given, default to 180
coast [DEBUG]: Projected values in meters: -1.80199e+07 1.80199e+07 -9.00996e+06 9.00996e+06
coast [DEBUG]: Computed automatic parameters using dimension scaling: 0.908088
coast [INFORMATION]: Map scale is 2402.66 km per cm or 1:2.40266e+08.
coast [INFORMATION]: -D option: Selected resolution -Dc
coast [DEBUG]: 1. GSHHG: GSHHGDIR set, trying /tmp/gmt-20240107-14473-f7ivwu/gmt-6.5.0/gshhg/binned_GSHHS_c.nc
coast [DEBUG]: 1. GSHHG: Failure, could not access /tmp/gmt-20240107-14473-f7ivwu/gmt-6.5.0/gshhg/binned_GSHHS_c.nc
coast [DEBUG]: GMT: 0. Will try to find subdir=conf stem = coastline suffix=.conf
coast [DEBUG]: GMT: 1. gmt_getsharepath trying current dir
coast [DEBUG]: GMT: 2. gmt_getsharepath trying USERDIR /Users/lwagner/.gmt
coast [DEBUG]: GMT: 3. gmt_getsharepath trying USERDIR subdir /Users/lwagner/.gmt/conf
coast [DEBUG]: GMT: 4. gmt_getsharepath trying SHAREDIR subdir /opt/homebrew/Cellar/gmt/6.5.0/share/gmt/conf
coast [DEBUG]: GMT: 5. gmt_getsharepath trying SHAREDIR /opt/homebrew/Cellar/gmt/6.5.0/share/gmt
coast [DEBUG]: GMT: 6. gmt_getsharepath failed
coast [DEBUG]: GMT: 0. Will try to find subdir=coast stem = coastline suffix=.conf
coast [DEBUG]: GMT: 1. gmt_getsharepath trying current dir
coast [DEBUG]: GMT: 2. gmt_getsharepath trying USERDIR /Users/lwagner/.gmt
coast [DEBUG]: GMT: 3. gmt_getsharepath trying USERDIR subdir /Users/lwagner/.gmt/coast
coast [DEBUG]: GMT: 4. gmt_getsharepath trying SHAREDIR subdir /opt/homebrew/Cellar/gmt/6.5.0/share/gmt/coast
coast [DEBUG]: GMT: 5. gmt_getsharepath trying SHAREDIR /opt/homebrew/Cellar/gmt/6.5.0/share/gmt
coast [DEBUG]: GMT: 6. gmt_getsharepath failed
coast [DEBUG]: 3. GSHHG: Trying via sharepath
coast [DEBUG]: GMT: 0. Will try to find subdir=coast stem = binned_GSHHS_c suffix=.nc
coast [DEBUG]: GMT: 1. gmt_getsharepath trying current dir
coast [DEBUG]: GMT: 2. gmt_getsharepath trying USERDIR /Users/lwagner/.gmt
coast [DEBUG]: GMT: 3. gmt_getsharepath trying USERDIR subdir /Users/lwagner/.gmt/coast
coast [DEBUG]: GMT: 4. gmt_getsharepath trying SHAREDIR subdir /opt/homebrew/Cellar/gmt/6.5.0/share/gmt/coast
coast [DEBUG]: 3. GSHHG: Trying /opt/homebrew/Cellar/gmt/6.5.0/share/gmt/coast/binned_GSHHS_c.nc
coast [DEBUG]: 3. GSHHG: Failure, could not access /opt/homebrew/Cellar/gmt/6.5.0/share/gmt/coast/binned_GSHHS_c.ncgshhg_version: cannot open file “/opt/homebrew/Cellar/gmt/6.5.0/share/gmt/coast/binned_GSHHS_c.nc” (-101).

coast [DEBUG]: 4. GSHHG: Trying via remote download
gshhg_version: cannot open file “/Users/lwagner/.gmt/geography/gshhg/binned_GSHHS_c.nc” (-101).
coast [NOTICE]: Downloading binned_GSHHS_c.nc for the first time - be patient
coast [DEBUG]: Delete /var/folders/qc/wt2jq2v965zdp1kttzrd5vy00000gq/T/binned_GSHHS_c.download
coast [DEBUG]: 5. GSHHG: Failure, could not access any GSHHG filesgshhg_version: cannot open file “/Users/lwagner/.gmt/geography/gshhg/binned_GSHHS_c.nc” (-101).

coast [WARNING]: GSHHG version 2.2.0 or newer is needed to use coastlines with GMT.
Get and install GSHHG from ftp://ftp.soest.hawaii.edu/gshhg/.
coast [ERROR]: Could not find file [GSHHG crude resolution shorelines]
coast [ERROR]: No GSHHG databases available - must abort


GMTCLibError Traceback (most recent call last)
Cell In[2], line 2
1 fig=pygmt.Figure()
----> 2 fig.coast(
3 region=“g”, projection=“H15c”, shorelines=“1p”, verbose=“d”)
4 fig.show()

File ~/anaconda3/envs/research/lib/python3.10/site-packages/pygmt/helpers/decorators.py:609, in use_alias..alias_decorator..new_module(*args, **kwargs)
603 msg = (
604 "Parameters ‘Y’ and ‘yshift’ are no longer supported since v0.12.0. "
605 “Use Figure.shift_origin(yshift=…) instead.”
606 )
607 raise GMTInvalidInput(msg)
→ 609 return module_func(*args, **kwargs)

File ~/anaconda3/envs/research/lib/python3.10/site-packages/pygmt/helpers/decorators.py:773, in kwargs_to_strings..converter..new_module(*args, **kwargs)
770 bound.arguments[“kwargs”][arg] = newvalue
772 # Execute the original function and return its output
→ 773 return module_func(*bound.args, **bound.kwargs)

File ~/anaconda3/envs/research/lib/python3.10/site-packages/pygmt/src/coast.py:230, in coast(self, **kwargs)
225 raise GMTInvalidInput(
226 “”“At least one of the following parameters must be specified:
227 lakes, land, water, rivers, borders, dcw, Q, or shorelines”“”
228 )
229 with Session() as lib:
→ 230 lib.call_module(module=“coast”, args=build_arg_list(kwargs))

File ~/anaconda3/envs/research/lib/python3.10/site-packages/pygmt/clib/session.py:659, in Session.call_module(self, module, args)
657 status = c_call_module(self.session_pointer, module.encode(), mode, argv)
658 if status != 0:
→ 659 raise GMTCLibError(
660 f"Module ‘{module}’ failed with status code {status}:\n{self._error_message}"
661 )

GMTCLibError: Module ‘coast’ failed with status code 79:
coast [ERROR]: Could not find file [GSHHG crude resolution shorelines]
coast [ERROR]: No GSHHG databases available - must abort

That’s weird. The same file can be accessed and opened in GMT CLI but not in PyGMT. Have you tried installing the GMT package from conda-forge instead?

no - but honestly, right now at least GMT is working… I’m worried that if I create a python installation as well, I’ll have neither PyGMT nor GMT. I’d take the risk if there was a reason you think this could fix it. Thoughts?

It sounds like at this point maybe this should be put in as a bug report? Thoughts?

Lara

I met the same issue, which has been solved by setting GMT_LIBRARY_PATH as suggested here.
GMT CLI used /opt/homebrew/Cellar/gmt/6.5.0_1/share/gmt/coast/binned_GSHHS_c.nc, whereas, after fixing the issue, PyGMT used path_to_anaconda/envs/obspy/share/gshhg-gmt/binned_GSHHS_c.nc. Hope it will help anyone who meets the same problem and ignores that “Common installation issues”.

1 Like