From 3fae13804f3cfd1d301a0196f2c36e2dabb0f9f7 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Thu, 28 Jan 2021 21:14:49 -0500 Subject: [PATCH 1/3] Display the original error message if failing to load the GMT library 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. ``` --- pygmt/clib/loading.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/clib/loading.py b/pygmt/clib/loading.py index be14b65b296..895edde74ac 100644 --- a/pygmt/clib/loading.py +++ b/pygmt/clib/loading.py @@ -43,8 +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 '{}'.\n {}.".format( + ", ".join(lib_fullnames), error ) ) return libgmt From 2d160b6cfc3e53e239f097316303fff10ef40bb3 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Fri, 29 Jan 2021 18:17:31 -0500 Subject: [PATCH 2/3] Update pygmt/clib/loading.py Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- pygmt/clib/loading.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/clib/loading.py b/pygmt/clib/loading.py index 895edde74ac..96d7b5c75a3 100644 --- a/pygmt/clib/loading.py +++ b/pygmt/clib/loading.py @@ -43,8 +43,8 @@ def load_libgmt(): error = err if error: raise GMTCLibNotFoundError( - "Error loading the GMT shared library '{}'.\n {}.".format( - ", ".join(lib_fullnames), error + "Error loading the GMT shared library " + f"'{', '.join(lib_fullnames)}'.\n {error}." ) ) return libgmt From 3cd70880c6786608a0900ed90fc6606f055f25f4 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Fri, 29 Jan 2021 23:54:27 -0500 Subject: [PATCH 3/3] Fix wrong syntax --- pygmt/clib/loading.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pygmt/clib/loading.py b/pygmt/clib/loading.py index 96d7b5c75a3..c98da792e82 100644 --- a/pygmt/clib/loading.py +++ b/pygmt/clib/loading.py @@ -44,8 +44,7 @@ def load_libgmt(): if error: raise GMTCLibNotFoundError( "Error loading the GMT shared library " - f"'{', '.join(lib_fullnames)}'.\n {error}." - ) + f"{', '.join(lib_fullnames)}.\n {error}." ) return libgmt