Installing PyGMT on Google Colab

How do you install PyGMT on Google Colab notebook.

1 Like

Try running following commands in Google Colab:

!wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
!chmod +x Miniconda3-latest-Linux-x86_64.sh
!bash ./Miniconda3-latest-Linux-x86_64.sh -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
sys.path.append('/usr/local/lib/python3.8/site-packages')
os.environ["GMT_LIBRARY_PATH"]="/usr/local/lib"

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.

++Ahmet

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 libgmt.so gives me the following message:

OSError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /usr/local/lib/././libtiledb.so.2.1)

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 (github.com)).

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 ?