Problem using pygmt with pip install

Hi, after installing pygmt (using pip) and creating a test file importing pygmt, when I run the file I get the following error: (I already tried in my computer with anaconda and everything run fine but I used anaconda, I want to install this with pip because I am installing it in a centos server with a little amount of space (only have 8gb left) and anaconda is quite heavy (6.3 Gb))

Traceback (most recent call last):
File “”, line 1, in
import pygmt
File “/usr/local/lib/python3.8/site-packages/pygmt/”, line 71, in
File “/usr/local/lib/python3.8/site-packages/pygmt/”, line 16, in begin
with Session() as lib:
File “/usr/local/lib/python3.8/site-packages/pygmt/clib/”, line 183, in enter
File “/usr/local/lib/python3.8/site-packages/pygmt/clib/”, line 330, in create
c_create_session = self.get_libgmt_func(
File “/usr/local/lib/python3.8/site-packages/pygmt/clib/”, line 282, in get_libgmt_func
self._libgmt = load_libgmt()
File “/usr/local/lib/python3.8/site-packages/pygmt/clib/”, line 59, in load_libgmt
raise GMTCLibNotFoundError("\n".join(error_msg))
pygmt.exceptions.GMTCLibNotFoundError: Error loading GMT shared library at ‘’. cannot open shared object file: No such file or directory

The documentation I use for the installation is this, I believe the problem is that I need to export the path of pygmt but it seem I am doing this wrong.
What I try was:

export GMT_LIBRARY_PATH=/usr/local/lib/python3.8/site-packages/pygmt/clib

But I still get the error above.
Thanks for reading until here.

PyGMT relies on GMT. When you run pip install pygmt, you only install the PyGMT package. The required GMT package (which is not written in Python) is still missing.

I think you have two choices:

  1. Install miniconda instead, which is much smaller than anaconda.
  2. Build GMT from source code, and then set GMT_LIBRARY_PATH to the path of the GMT library
1 Like

Thanks, I already installed miniconda3 and build from source, the environment is working fine and pygmt is working correctly.