Installing PyGMT on Google Colab

How do you install PyGMT on Google Colab notebook.

1 Like

Try running following commands in Google Colab:

!chmod +x
!bash ./ -bfp /usr/local
!conda update conda -y -q
!conda config --prepend channels conda-forge
!conda install -q -y --prefix /usr/local python=3.8 pygmt

import sys
import os

Then you should be able to use pygmt:

import pygmt
1 Like

@seisman Worked well for me, thanks!

Dear @seisman,
Do we have to install pygmt everytime we access Colab? Because after completing my work and come back couple of days later, I have to run your codes again.

Best regards from Istanbul.


Yes, I believe so. Google colab doesn’t save your environment.

Yeah, that was my belief, too. Pity.

It was working pretty well until a few days ago. Now I got this error;

1 Like

I can reproduce your issue. Loading the gives me the following message:

OSError: /usr/lib/x86_64-linux-gnu/ version `GLIBCXX_3.4.26' not found (required by /usr/local/lib/././

I think some other conda-forge packages are broken.

Did this ever get resolved, or is there an issue for this?

1 Like

I’m not sure. The PyGMT tests all work well, but the try-gmt binder seems broken recently (GMT.jl is broken on Binder · Issue #15 · GenericMappingTools/try-gmt (

I have the same issue

Hello. Any news on this ?
I got the same problem (just runinng the colab test I got the same error)

Any help ?

Solved here:

To whom may concern, here is the latest solution to install PyGMT on Google Colab: