I am installing pygmt using anaconda navigator on Windows, and running it in jupyter-lab. Nominally, it seems to work fine; I get sensible output for the version info:
import pygmt
pygmt.show_versions()
PyGMT information:
version: v0.7.0
System information:
python: 3.9.12 (main, Apr 4 2022, 05:22:27) [MSC v.1916 64 bit (AMD64)]
executable: C:\Users\eol\Anaconda3\envs\escape\python.exe
machine: Windows-10-10.0.19043-SP0
Dependency information:
numpy: 1.23.1
pandas: 1.4.3
xarray: 2022.6.0
netCDF4: 1.6.0
packaging: 21.3
geopandas: None
ghostscript: 9.54.0
gmt: 6.4.0
GMT library information:
binary dir: C:/Users/eol/Anaconda3/envs/escape
cores: 12
grid layout: rows
library path: C:/Users/eol/Anaconda3/envs/escape/Library/bin/gmt.dll
padding: 2
plugin dir: C:/Users/eol/Anaconda3/envs/escape/Library/bin/gmt_plugins
share dir: C:/Users/eol/Anaconda3/envs/escape/Library/share/gmt
version: 6.4.0
However, when I run the example plot commands (or any other plot), I get an error related to a wrong version of ghostscript, caused by fig.show(): there is a long traceback which ends in the following:
File ~\Anaconda3\envs\escape\lib\site-packages\pygmt\figure.py:248, in Figure.psconvert(self, icc_gray, **kwargs)
245 raise GMTInvalidInput("The 'prefix' must be specified.") from err
247 with Session() as lib:
--> 248 lib.call_module(
249 module="psconvert", args=f"{prefix_arg} {build_arg_string(kwargs)}"
250 )
File ~\Anaconda3\envs\escape\lib\site-packages\pygmt\clib\session.py:506, in Session.call_module(self, module, args)
502 status = c_call_module(
503 self.session_pointer, module.encode(), mode, args.encode()
504 )
505 if status != 0:
--> 506 raise GMTCLibError(
507 f"Module '{module}' failed with status code {status}:\n{self._error_message}"
508 )
GMTCLibError: Module 'psconvert' failed with status code 79:
psconvert [ERROR]: System call [@"C:\Program Files (x86)\GPLGS\gswin32c.exe" -q -dNOPAUSE -dBATCH -dNOSAFER -dMaxBitmap=2147483647 -dGraphicsAlphaBits=2 -dTextAlphaBits=2 -sDEVICE=png16m -g136530x136530 -r300 -sOutputFile="C:\Users\eol\AppData\Local\Temp\2e939da376b147f888e603804d90dbb6-preview-_930b8h4\2e939da376b147f888e603804d90dbb6.png" "C:/Users/eol/.gmt/sessions/gmt_session.6632/psconvert_14224d.eps"] returned error -1073741819.
This error seems to be caused by psconvert finding a very old version of gs, located at C:\Program Files (x86)\GPLGS\gswin32c.exe. I found that this ghostscript does indeed exist, but is version 8.15 from 2004!
I can’t easily uninstall this version of gs (it may be needed by something else), and am wondering if there is a way to redirect psconvert to find the correct, 9.54 version of gs, which was installed as a dependency in the conda directory? It seems like a bug, psconvert should be set up to only ever find this version and not go hunting around the computer for old ones.