Can't import pygmt after installing GMT from Mac package

Hello,

I’ve installed GMT using the most recent Mac package (gmt-6.2.0-darwin-x86_64.dmg) and tested that it works. I then installed pygmt via pip. However, “import pygmt” from the Python command line produces the following:

import pygmt
Traceback (most recent call last):
File “”, line 1, in
File “/opt/anaconda3/lib/python3.8/site-packages/pygmt/init.py”, line 57, in
_begin()
File “/opt/anaconda3/lib/python3.8/site-packages/pygmt/session_management.py”, line 16, in begin
with Session() as lib:
File “/opt/anaconda3/lib/python3.8/site-packages/pygmt/clib/session.py”, line 185, in enter
self.create(“pygmt-session”)
File “/opt/anaconda3/lib/python3.8/site-packages/pygmt/clib/session.py”, line 332, in create
c_create_session = self.get_libgmt_func(
File “/opt/anaconda3/lib/python3.8/site-packages/pygmt/clib/session.py”, line 284, in get_libgmt_func
self._libgmt = load_libgmt()
File “/opt/anaconda3/lib/python3.8/site-packages/pygmt/clib/loading.py”, line 59, in load_libgmt
raise GMTCLibNotFoundError(“\n”.join(error_msg))
pygmt.exceptions.GMTCLibNotFoundError: Error loading GMT shared library at ‘/Applications/GMT-6.2.0.app/Contents/Resources/lib/libgmt.dylib’.
dlopen(/Applications/GMT-6.2.0.app/Contents/Resources/lib/libgmt.dylib, 6): Library not loaded: @executable_path/…/lib/libcurl.4.dylib
Referenced from: /Applications/GMT-6.2.0.app/Contents/Resources/lib/libgmt.6.2.0.dylib
Reason: Incompatible library version: libgmt.dylib requires version 12.0.0 or later, but libcurl.4.dylib provides version 11.0.0
Error loading GMT shared library at ‘libgmt.dylib’.
dlopen(libgmt.dylib, 6): image not found

This is made even more confusing when I check on libcurl.4.dylib:

otool -L libcurl.4.dylib
libcurl.4.dylib:
@executable_path/…/lib/libcurl.4.dylib (compatibility version 12.0.0, current version 12.0.0)

In case it matters, I’m on Big Sur 11.6.

Any suggestion would be awesome.

Thanks,
Ryan

I’m just new at GMT, but I have both GMT and PyGMT running on MacOS 11.6. I installed the GMT dmg. But I also just independently installed the PyGMT and GMT python modules from conda-forge as per: https://www.pygmt.org/latest/install.html#installing-gmt-and-other-dependencies

Yes, it’s a known issue that the macOS bundle doesn’t work for GMT wrappers like PyGMT, GMT.jl or GMT/Matlab.

macOS bundle doesn’t work for pygmt · Issue #1930 · GenericMappingTools/gmt (github.com)

Thanks, this is what I did on my Mac and a remote Linux machine, and it was successful.