Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

psconvert issue on Windows #3704

Closed
mdtanker opened this issue Dec 20, 2024 · 3 comments
Closed

psconvert issue on Windows #3704

mdtanker opened this issue Dec 20, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@mdtanker
Copy link
Contributor

Description of the problem

After a fresh install of pygmt v0.13 on Windows 10 when I try and display a figure with fig.show() I receive a psconvert error. I've run into this issue a few times, and unsure how I ended up fixing it in the past.

According this this issue I tried installing Ghostscript with the official installer, but received the same error still.

The error suggests that psconvert is finding the correct gswin64c.exe, which was an issue for others: #2038, https://forum.generic-mapping-tools.org/t/pygmt-finding-old-ghostscript-with-conda-on-windows/3174/5

Explicitly specifying the gswin path in fig.show() also doesn't help, as it did in this issue

C:\Users\mattd>gswin64c --version
10.04.0
C:\Users\mattd>where gswin64c
C:\Program Files\gs\gs10.04.0\bin\gswin64c.exe

Minimal Complete Verifiable Example

import pygmt
fig = pygmt.Figure()
fig.basemap(region=[0, 1, 0, 1], projection="X5c", frame="af")
pygmt.config(GMT_VERBOSE="d")
fig.show()
# fig.show(gs_path="C:\\Program Files\\gs\\gs10.04.0\\bin\\gswin64c")
# fig.show(gs_path="C:\\Users\\mattd\\miniforge3\\envs\\pygmt\\Library\\bin\\gswin64c.exe")

Full error message

pygmt-session [DEBUG]: Exit:  gmt_reload_settings
pygmt-session [DEBUG]: Enter: gmtlib_plot_C_format
pygmt-session [DEBUG]: Exit:  gmtlib_plot_C_format
pygmt-session [DEBUG]: Enter: gmtinit_get_history
pygmt-session [DEBUG]: gmtlib_get_graphics_item: Fig: 8 Subplot: 2 Panel: () Inset: 0
pygmt-session [DEBUG]: Enter: gmt_hash_init
pygmt-session [DEBUG]: Exit:  gmt_hash_init
pygmt-session [DEBUG]: Failed to release lock (Error <158>: The segment is already unlocked.
)
pygmt-session [DEBUG]: Exit:  gmtinit_get_history
pygmt-session [DEBUG]: Initialize FFTW with 16 threads.
pygmt-session [DEBUG]: GMT_Create_Session initialized GMT structure
pygmt-session [DEBUG]: Shared Library # 0 (core). Path = C:/Users/mattd/miniforge3/envs/pygmt/Library/bin/gmt.dll
pygmt-session [DEBUG]: Loading GMT plugins from: C:/Users/mattd/miniforge3/envs/pygmt/Library/bin/gmt_plugins
pygmt-session [DEBUG]: Shared Library # 1 (supplements). Path = C:/Users/mattd/miniforge3/envs/pygmt/Library/bin/gmt_plugins/supplements.dll
pygmt-session [DEBUG]: GMT now running in modern mode [Session ID = 4589478510224c4296e7303a8557035b]
pygmt-session [DEBUG]: Revised options: ac3ca753b720465d8b2a1d523bf7d71e -
figure [DEBUG]: New figure: 9	ac3ca753b720465d8b2a1d523bf7d71e	-
gmtset [DEBUG]: gmtlib_get_graphics_item: Fig: 9 Subplot: 2 Panel: () Inset: 0
pygmt-session [DEBUG]: Exit:  gmt_reload_settings
pygmt-session [DEBUG]: Enter: gmtlib_plot_C_format
pygmt-session [DEBUG]: Exit:  gmtlib_plot_C_format
pygmt-session [DEBUG]: Enter: gmtinit_get_history
pygmt-session [DEBUG]: gmtlib_get_graphics_item: Fig: 9 Subplot: 2 Panel: () Inset: 0
pygmt-session [DEBUG]: Enter: gmt_hash_init
pygmt-session [DEBUG]: Exit:  gmt_hash_init
pygmt-session [DEBUG]: Failed to release lock (Error <158>: The segment is already unlocked.
)
pygmt-session [DEBUG]: Exit:  gmtinit_get_history
pygmt-session [DEBUG]: Initialize FFTW with 16 threads.
pygmt-session [DEBUG]: GMT_Create_Session initialized GMT structure
pygmt-session [DEBUG]: Shared Library # 0 (core). Path = C:/Users/mattd/miniforge3/envs/pygmt/Library/bin/gmt.dll
pygmt-session [DEBUG]: Loading GMT plugins from: C:/Users/mattd/miniforge3/envs/pygmt/Library/bin/gmt_plugins
pygmt-session [DEBUG]: Shared Library # 1 (supplements). Path = C:/Users/mattd/miniforge3/envs/pygmt/Library/bin/gmt_plugins/supplements.dll
pygmt-session [DEBUG]: GMT now running in modern mode [Session ID = 4589478510224c4296e7303a8557035b]
pygmt-session [DEBUG]: Revised options: ac3ca753b720465d8b2a1d523bf7d71e -
pygmt-session [DEBUG]: Exit:  gmt_reload_settings
pygmt-session [DEBUG]: Enter: gmtlib_plot_C_format
pygmt-session [DEBUG]: Exit:  gmtlib_plot_C_format
pygmt-session [DEBUG]: Enter: gmtinit_get_history
pygmt-session [DEBUG]: gmtlib_get_graphics_item: Fig: 9 Subplot: 2 Panel: () Inset: 0
pygmt-session [DEBUG]: Enter: gmt_hash_init
pygmt-session [DEBUG]: Exit:  gmt_hash_init
pygmt-session [DEBUG]: Failed to release lock (Error <158>: The segment is already unlocked.
)
pygmt-session [DEBUG]: Exit:  gmtinit_get_history
pygmt-session [DEBUG]: Initialize FFTW with 16 threads.
pygmt-session [DEBUG]: GMT_Create_Session initialized GMT structure
pygmt-session [DEBUG]: Shared Library # 0 (core). Path = C:/Users/mattd/miniforge3/envs/pygmt/Library/bin/gmt.dll
pygmt-session [DEBUG]: Loading GMT plugins from: C:/Users/mattd/miniforge3/envs/pygmt/Library/bin/gmt_plugins
pygmt-session [DEBUG]: Shared Library # 1 (supplements). Path = C:/Users/mattd/miniforge3/envs/pygmt/Library/bin/gmt_plugins/supplements.dll
pygmt-session [DEBUG]: GMT now running in modern mode [Session ID = 4589478510224c4296e7303a8557035b]
pygmt-session [DEBUG]: Revised options: -A -E300 -FC:/Users/mattd/AppData/Local/Temp/ac3ca753b720465d8b2a1d523bf7d71e-preview-7d10kbpk/ac3ca753b720465d8b2a1d523bf7d71e -Qg2 -Qt2 -Tg
psconvert [DEBUG]: Ghostscript executable full name:
psconvert [DEBUG]: gmt_run_process_get_first_line: Pass to popen: ["C:\Program Files\gs\gs10.04.0\bin\gswin64c.exe" --version 2> NUL]
psconvert [DEBUG]: "C:\Program Files\gs\gs10.04.0\bin\gswin64c.exe" --version 2> NUL was successful
psconvert [DEBUG]: Ghostscript version: 10.04.0
psconvert [DEBUG]: Use PS filename C:/Users/mattd/.gmt/sessions/gmt_session.4589478510224c4296e7303a8557035b/gmt_9.ps-
psconvert [DEBUG]: Hidden PS file C:/Users/mattd/.gmt/sessions/gmt_session.4589478510224c4296e7303a8557035b/gmt_9.ps- found
psconvert [DEBUG]: Complete partial PS file C:/Users/mattd/.gmt/sessions/gmt_session.4589478510224c4296e7303a8557035b/gmt_9.ps-
psconvert [DEBUG]: Size of half-baked PS file = 22991.
psconvert [DEBUG]: Fattened up PS file C:/Users/mattd/.gmt/sessions/gmt_session.4589478510224c4296e7303a8557035b/gmt_9.ps-
psconvert [INFORMATION]: Processing C:/Users/mattd/.gmt/sessions/gmt_session.4589478510224c4296e7303a8557035b/gmt_9.ps-...
psconvert [INFORMATION]: Find HiResBoundingBox ...
psconvert [DEBUG]: Running: @"C:\Program Files\gs\gs10.04.0\bin\gswin64c.exe" -q -dNOSAFER -dNOPAUSE -dBATCH -sDEVICE=bbox -DPSL_no_pagefill -dMaxBitmap=2147483647 -dUseFastColor=true "C:/Users/mattd/.gmt/sessions/gmt_session.4589478510224c4296e7303a8557035b/gmt_9.ps-" 2> "C:/Users/mattd/.gmt/sessions/gmt_session.4589478510224c4296e7303a8557035b/psconvert_31636c.bb"
psconvert [ERROR]: System call [@"C:\Program Files\gs\gs10.04.0\bin\gswin64c.exe" -q -dNOSAFER -dNOPAUSE -dBATCH -sDEVICE=bbox -DPSL_no_pagefill -dMaxBitmap=2147483647 -dUseFastColor=true "C:/Users/mattd/.gmt/sessions/gmt_session.4589478510224c4296e7303a8557035b/gmt_9.ps-" 2> "C:/Users/mattd/.gmt/sessions/gmt_session.4589478510224c4296e7303a8557035b/psconvert_31636c.bb"] returned error 1.
psconvert [DEBUG]: Delete C:/Users/mattd/.gmt/sessions/gmt_session.4589478510224c4296e7303a8557035b/psconvert_31636c.bb

---------------------------------------------------------------------------
GMTCLibError                              Traceback (most recent call last)
Cell In[10], line 5
      3 fig.basemap(region=[0, 1, 0, 1], projection="X5c", frame="af")
      4 pygmt.config(GMT_VERBOSE="d")
----> 5 fig.show()
      6 # fig.show(gs_path="C:\\Program Files\\gs\\gs10.04.0\\bin\\gswin64c")
      7 # fig.show(gs_path="C:\\Users\\mattd\\miniforge3\\envs\\pygmt\\Library\\bin\\gswin64c.exe")

File c:\Users\mattd\miniforge3\envs\pygmt\Lib\site-packages\pygmt\figure.py:478, in Figure.show(self, method, dpi, width, waiting, **kwargs)
    472     if not _HAS_IPYTHON:
    473         raise GMTError(
    474             "Notebook display is selected, but IPython is not available. "
    475             "Make sure you have IPython installed, "
    476             "or run the script in a Jupyter notebook."
    477         )
--> 478     png = self._preview(
    479         fmt="png", dpi=dpi, anti_alias=True, as_bytes=True, **kwargs
    480     )
    481     IPython.display.display(IPython.display.Image(data=png, width=width))
    482 case "external":

File c:\Users\mattd\miniforge3\envs\pygmt\Lib\site-packages\pygmt\figure.py:517, in Figure._preview(self, fmt, dpi, as_bytes, **kwargs)
    496 """
    497 Grab a preview of the figure.
    498 
   (...)
    514     file. Else, it is the file content loaded as a bytes string.
    515 """
    516 fname = Path(self._preview_dir.name) / f"{self._name}.{fmt}"
--> 517 self.savefig(fname, dpi=dpi, **kwargs)
    518 if as_bytes:
    519     return fname.read_bytes()

File c:\Users\mattd\miniforge3\envs\pygmt\Lib\site-packages\pygmt\figure.py:389, in Figure.savefig(self, fname, transparent, crop, anti_alias, show, worldfile, **kwargs)
    384         raise GMTInvalidInput(
    385             f"Saving a world file is not supported for '{ext}' format."
    386         )
    387     kwargs["W"] = True
--> 389 self.psconvert(prefix=prefix, fmt=fmt, crop=crop, **kwargs)
    391 # Remove the .pgw world file if exists
    392 # Not necessary after GMT 6.5.0.
    393 # See upstream fix https://github.com/GenericMappingTools/gmt/pull/7865
    394 if ext == "tiff":

File c:\Users\mattd\miniforge3\envs\pygmt\Lib\site-packages\pygmt\helpers\decorators.py:609, in use_alias.<locals>.alias_decorator.<locals>.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 c:\Users\mattd\miniforge3\envs\pygmt\Lib\site-packages\pygmt\helpers\decorators.py:773, in kwargs_to_strings.<locals>.converter.<locals>.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 c:\Users\mattd\miniforge3\envs\pygmt\Lib\site-packages\pygmt\figure.py:275, in Figure.psconvert(self, **kwargs)
    270     raise FileNotFoundError(
    271         f"No such directory: '{prefix_path}', please create it first."
    272     )
    274 with Session() as lib:
--> 275     lib.call_module(module="psconvert", args=build_arg_list(kwargs))

File c:\Users\mattd\miniforge3\envs\pygmt\Lib\site-packages\pygmt\clib\session.py:656, in Session.call_module(self, module, args)
    654 status = c_call_module(self.session_pointer, module.encode(), mode, argv)
    655 if status != 0:
--> 656     raise GMTCLibError(
    657         f"Module '{module}' failed with status code {status}:\n{self._error_message}"
    658     )

GMTCLibError: Module 'psconvert' failed with status code 79:
psconvert [ERROR]: System call [@"C:\Program Files\gs\gs10.04.0\bin\gswin64c.exe" -q -dNOSAFER -dNOPAUSE -dBATCH -sDEVICE=bbox -DPSL_no_pagefill -dMaxBitmap=2147483647 -dUseFastColor=true "C:/Users/mattd/.gmt/sessions/gmt_session.4589478510224c4296e7303a8557035b/gmt_9.ps-" 2> "C:/Users/mattd/.gmt/sessions/gmt_session.4589478510224c4296e7303a8557035b/psconvert_31636c.bb"] returned error 1.

System information

PyGMT information:
  version: v0.13.0
System information:
  python: 3.13.1 | packaged by conda-forge | (main, Dec  5 2024, 21:02:16) [MSC v.1942 64 bit (AMD64)]
  executable: c:\Users\mattd\miniforge3\envs\pygmt\python.exe
  machine: Windows-10-10.0.19045-SP0
Dependency information:
  numpy: 2.2.0
  pandas: 2.2.3
  xarray: 2024.11.0
  netCDF4: 1.7.2
  packaging: 24.2
  contextily: None
  geopandas: None
  IPython: 8.30.0
  rioxarray: None
  gdal: 3.10.0
  ghostscript: 10.04.0
GMT library information:
  version: 6.5.0
  padding: 2
  share dir: C:/Users/mattd/miniforge3/envs/pygmt/Library/share/gmt
  plugin dir: C:/Users/mattd/miniforge3/envs/pygmt/Library/bin/gmt_plugins
  library path: C:/Users/mattd/miniforge3/envs/pygmt/Library/bin/gmt.dll
  cores: 16
  grid layout: rows
  image layout: 
  binary version: 6.5.0
@mdtanker mdtanker added the bug Something isn't working label Dec 20, 2024
@seisman
Copy link
Member

seisman commented Dec 21, 2024

The error message tells that the following command fails:

@"C:\Program Files\gs\gs10.04.0\bin\gswin64c.exe" -q -dNOSAFER -dNOPAUSE -dBATCH -sDEVICE=bbox -DPSL_no_pagefill -dMaxBitmap=2147483647 -dUseFastColor=true "C:/Users/mattd/.gmt/sessions/gmt_session.4589478510224c4296e7303a8557035b/gmt_9.ps-" 2> "C:/Users/mattd/.gmt/sessions/gmt_session.4589478510224c4296e7303a8557035b/psconvert_31636c.bb"

Could you please run this command manually in CMD? The actual file path may need to change.

@seisman
Copy link
Member

seisman commented Dec 27, 2024

No feedback in one week. Closing it now. Feel free to reopen it if you still have the issue.

@seisman seisman closed this as not planned Won't fix, can't repro, duplicate, stale Dec 27, 2024
@mdtanker
Copy link
Contributor Author

mdtanker commented Jan 7, 2025

Sorry for the delay! I've run that command in CMD. There were no errors or messages, but the file psconvert_100004c.bb was created in the GMT session folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants