You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I also noticed it yesterday. It's weird that the commands in the notebook install "python 3.9" but the python version in the error message says it's python3.6.
I also noticed it yesterday. It's weird that the commands in the notebook install "python 3.9" but the python version in the error message says it's python3.6.
Essentially, you'll install Conda, and then GMT/PyGMT. Note that this should be done in parts, and the first two cells take about 3 minutes to install everything. Good luck.
Installing GMT using !sudo apt-get install gmt gmt-dcw gmt-gshhg takes much longer than using conda/mamba, which causes most users to give up on the process. I myself abandoned the idea of apt install some time ago. I recommend using conda install.
I managed to get PyGMT working in Google Colab without using condacolab.
The issue seems to be a version mismatch between the system libraries available in Colab's default Linux environment and the latest PyGMT release.
Since Colab runs on an LTS version of Ubuntu, so the official apt repositories only provide GMT 6.4.0. The latest version of PyGMT requires GMT 6.5.0+, which causes a GMTVersionError if you try to install it directly.
To fix this, I installed the system dependencies via apt and then pinned PyGMT to v0.11.0, which is the last version compatible with GMT 6.4.0.
Here is a link to the Notebook I just created and worked for me:
Activity
seisman commentedon Feb 17, 2021
I also noticed it yesterday. It's weird that the commands in the notebook install "python 3.9" but the python version in the error message says it's python3.6.
[-]pygmt import error[/-][+]pygmt import error on google collaboratory[/+]weiji14 commentedon Jun 6, 2021
After doing some reading (e.g. https://towardsdatascience.com/conda-google-colab-75f7c867a522), it seems that we need to pin conda's Python version to be the same as that on Google Collaboratory (currently Python 3.7) instead of the Miniconda default (Python 3.9). However, I tried getting a Python 3.7 installer from https://repo.anaconda.com/miniconda/, and it still produces a DistributionNotFound error (as Liam and a forum user at https://forum.generic-mapping-tools.org/t/installing-pygmt-on-google-colab/898/12 reported). So needs a bit more work somehow.
[-]pygmt import error on google collaboratory[/-][+]pygmt import error on google colaboratory[/+]andrebelem commentedon Jun 20, 2021
I managed to use pygmt in the colab "installing GMT6 fresh".
Take a look at https://github.com/andrebelem/pythonverse/blob/main/PyGMT_on_COLAB.ipynb and feel free to incorporate it in the try-gmt.
I-Hamama commentedon Mar 4, 2024
Try to reinstall GMT and ghost script and refer to the libgmt.so.6
!sudo apt-get update
!sudo apt-get install gmt gmt-dcw gmt-gshhg
!sudo apt-get install -y ghostscript
!pip install pygmt
import os
!ln -s /lib/x86_64-linux-gnu/libgmt.so.6 /lib/x86_64-linux-gnu/libgmt.so
os.environ['LD_LIBRARY_PATH'] = ' /lib/x86_64-linux-gnu/libgmt.so'
Should work with these commands
andrebelem commentedon Mar 4, 2024
Two years ago, I created an example of how to use PyGMT in COLAB. I've updated the example now in the latest version of COLAB (March 2024), which you can see here: https://github.com/andrebelem/pythonverse/blob/main/Using_pygmt_in_COLAB_[version_2023].ipynb.
Essentially, you'll install Conda, and then GMT/PyGMT. Note that this should be done in parts, and the first two cells take about 3 minutes to install everything. Good luck.
I-Hamama commentedon Mar 4, 2024
PyGMT can't recognize to the libgmt.so under Google Colab. So, it is important to refer the path of libgmt.so in linux system which google are using
!ln -s /lib/x86_64-linux-gnu/libgmt.so.6 /lib/x86_64-linux-gnu/libgmt.so
What I did just adding alias of libgmt.so.6 and I reinstalled the GMT and ghost script.
It works well. I didn't try to use conda but good to know 2 ways of solving the problem
Thanks
andrebelem commentedon Mar 4, 2024
Installing GMT using
!sudo apt-get install gmt gmt-dcw gmt-gshhgtakes much longer than using conda/mamba, which causes most users to give up on the process. I myself abandoned the idea ofapt installsome time ago. I recommend using conda install.SeismoFelix commentedon Feb 11, 2026
Hello @andrebelem
I just followed your Notebook instructions and failed. I wonder if Colab has changed since the last time you replied to this issue.
Best regards,
Felix
SeismoFelix commentedon Feb 11, 2026
I managed to get PyGMT working in Google Colab without using condacolab.
The issue seems to be a version mismatch between the system libraries available in Colab's default Linux environment and the latest PyGMT release.
Since Colab runs on an LTS version of Ubuntu, so the official apt repositories only provide GMT 6.4.0. The latest version of PyGMT requires GMT 6.5.0+, which causes a GMTVersionError if you try to install it directly.
To fix this, I installed the system dependencies via apt and then pinned PyGMT to v0.11.0, which is the last version compatible with GMT 6.4.0.
Here is a link to the Notebook I just created and worked for me:
https://colab.research.google.com/drive/1BFWdQJyeAJeI2xZPXEK0G8JfxZmCy7Q0?usp=sharing
naliboff commentedon Feb 23, 2026
@SeismoFelix - Thank you, this worked perfectly on my end and the dependencies installation took less than 30 seconds.