Skip to content

Commit

Permalink
Improve the error message when PyGMT fails to load the GMT library (#814
Browse files Browse the repository at this point in the history
)

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]>
  • Loading branch information
seisman and weiji14 authored Jan 30, 2021
1 parent 7c35bb0 commit ef628bc
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pygmt/clib/loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ def load_libgmt():
error = err
if error:
raise GMTCLibNotFoundError(
"Error loading the GMT shared library '{}':".format(
", ".join(lib_fullnames)
)
"Error loading the GMT shared library "
f"{', '.join(lib_fullnames)}.\n {error}."
)
return libgmt

Expand Down

0 comments on commit ef628bc

Please sign in to comment.