Skip to content

Commit ef628bc

Browse files
seismanweiji14
andauthored
Improve the error message when PyGMT fails to load the GMT library (#814)
When PyGMT fails to load the GMT library, it raises an error: ``` GMTCLibNotFoundError: Error loading the GMT shared library '/opt/GMT-6.1.1/lib/libgmt.dylib'. ``` However, it's still unclear why it fails. After this PR, the error message will contain the original error message. For example: ``` GMTCLibNotFoundError: Error loading the GMT shared library '/opt/GMT-6.1.1/lib/libgmt.dylib'. dlopen(/opt/GMT-6.1.1/lib/libgmt.dylib, 6): Library not loaded: @rpath/libnetcdf.15.dylib Referenced from: /opt/GMT-6.1.1/lib/libgmt.6.1.1.dylib Reason: image not found. ``` Co-authored-by: Wei Ji <[email protected]>
1 parent 7c35bb0 commit ef628bc

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

pygmt/clib/loading.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ def load_libgmt():
4343
error = err
4444
if error:
4545
raise GMTCLibNotFoundError(
46-
"Error loading the GMT shared library '{}':".format(
47-
", ".join(lib_fullnames)
48-
)
46+
"Error loading the GMT shared library "
47+
f"{', '.join(lib_fullnames)}.\n {error}."
4948
)
5049
return libgmt
5150

0 commit comments

Comments
 (0)