PyGMT installation problems


I have PyCharm (Python 3.8) installed in my Macbook (BigSur) and works properly. I would like to highlight that I am new in this language.

I have followed the instructions provided at to install PyGMT.
.- Dependencies installed.
.- I have executed the following instructions to install GMT and other dependencies:
conda config --prepend channels conda-forge
conda create --name pygmt python=3.9 numpy pandas xarray netcdf4 packaging GMT
conda activate pygmt

.- I have executed the following instructions to install PyGMT :

conda install pygmt

When from PyCharm I execute some simple instructions to see that everything is OK

import pygmt

The Pycharm env prompts :slight_smile:

Traceback (most recent call last):
File “/Users/manuelcatalan/Desktop/pythonProject/”, line 10, in
import pygmt
File “/Users/manuelcatalan/Desktop/pythonProject/venv/lib/python3.8/site-packages/pygmt/”, line 70, in
File “/Users/manuelcatalan/Desktop/pythonProject/venv/lib/python3.8/site-packages/pygmt/”, line 16, in begin
with Session() as lib:
File “/Users/manuelcatalan/Desktop/pythonProject/venv/lib/python3.8/site-packages/pygmt/clib/”, line 183, in enter
File “/Users/manuelcatalan/Desktop/pythonProject/venv/lib/python3.8/site-packages/pygmt/clib/”, line 329, in create
c_create_session = self.get_libgmt_func(
File “/Users/manuelcatalan/Desktop/pythonProject/venv/lib/python3.8/site-packages/pygmt/clib/”, line 281, in get_libgmt_func
self._libgmt = load_libgmt()
File “/Users/manuelcatalan/Desktop/pythonProject/venv/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 ‘libgmt.dylib’.
dlopen(libgmt.dylib, 6): image not found

I would like to highlight that I have executed from Terminal: export GMT_LIBRARY_PATH=$HOME/anaconda3/envs/pygmt/lib

Please could you help me?



Hi @manencatalan, sorry for the late reply. Could you try looking at the forum post at pyGMT doesn't run on Pycharm but Jupyter and see if it helps? Maybe @zersorger could help you out with the PyCharm setup.

Just as a quick note, your conda create install step suggests you have installed Python 3.9 but the error message says Python 3.8, so you will need to find out how to use the correct Python virtual environment. Maybe something in the PyCharm editor settings?