# Installing PyGMT on Google Colab

**URL:** <https://forum.generic-mapping-tools.org/t/installing-pygmt-on-google-colab/898>\
**Category:** PyGMT Q&A\
**Created:** [September 21, 2020, 2:28pm UTC](https://forum.generic-mapping-tools.org/t/installing-pygmt-on-google-colab/898 "2020-09-21T14:28:50Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![sudhir2016](https://avatars.discourse-cdn.com/v4/letter/s/aca169/32.png) [@sudhir2016](https://forum.generic-mapping-tools.org/u/sudhir2016)\
**Post date:** [September 21, 2020, 2:28pm UTC](https://forum.generic-mapping-tools.org/t/installing-pygmt-on-google-colab/898/1 "2020-09-21T14:28:50Z")

</div>

How do you install PyGMT on Google Colab notebook.

---

<div class="post-metadata">

**Author:** ![seisman](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/seisman/32/4_2.png) [@seisman](https://forum.generic-mapping-tools.org/u/seisman)\
**Post date:** [September 21, 2020, 4:31pm UTC](https://forum.generic-mapping-tools.org/t/installing-pygmt-on-google-colab/898/2 "2020-09-21T16:31:47Z")

</div>

Try running following commands in Google Colab:

```auto
!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:

```auto
import pygmt

```

---

<div class="post-metadata">

**Author:** ![emetdan](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/emetdan/32/936_2.png) [@emetdan](https://forum.generic-mapping-tools.org/u/emetdan)\
**Post date:** [October 8, 2020, 5:24pm UTC](https://forum.generic-mapping-tools.org/t/installing-pygmt-on-google-colab/898/3 "2020-10-08T17:24:28Z")

</div>

@seisman Worked well for me, thanks!

---

<div class="post-metadata">

**Author:** ![ahmetanildindar](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/ahmetanildindar/32/119_2.png) [@ahmetanildindar](https://forum.generic-mapping-tools.org/u/ahmetanildindar)\
**Post date:** [December 22, 2020, 6:52pm UTC](https://forum.generic-mapping-tools.org/t/installing-pygmt-on-google-colab/898/4 "2020-12-22T18:52:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![seisman](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/seisman/32/4_2.png) [@seisman](https://forum.generic-mapping-tools.org/u/seisman)\
**Post date:** [December 22, 2020, 7:56pm UTC](https://forum.generic-mapping-tools.org/t/installing-pygmt-on-google-colab/898/5 "2020-12-22T19:56:29Z")

</div>

> [@ahmetanildindar](#):
>
> Do we have to install pygmt everytime we access Colab?

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

---

<div class="post-metadata">

**Author:** ![ahmetanildindar](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/ahmetanildindar/32/119_2.png) [@ahmetanildindar](https://forum.generic-mapping-tools.org/u/ahmetanildindar)\
**Post date:** [December 22, 2020, 8:02pm UTC](https://forum.generic-mapping-tools.org/t/installing-pygmt-on-google-colab/898/6 "2020-12-22T20:02:29Z")

</div>

Yeah, that was my belief, too. Pity.

---

<div class="post-metadata">

**Author:** ![seismiclover](https://avatars.discourse-cdn.com/v4/letter/s/9fc348/32.png) [@seismiclover](https://forum.generic-mapping-tools.org/u/seismiclover)\
**Post date:** [January 14, 2021, 10:14am UTC](https://forum.generic-mapping-tools.org/t/installing-pygmt-on-google-colab/898/7 "2021-01-14T10:14:09Z")

</div>

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

 ![image](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/1X/c7b24f8a5179eeb6f9954f54dacd55432b50592d.png)

---

<div class="post-metadata">

**Author:** ![seisman](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/seisman/32/4_2.png) [@seisman](https://forum.generic-mapping-tools.org/u/seisman)\
**Post date:** [January 14, 2021, 8:25pm UTC](https://forum.generic-mapping-tools.org/t/installing-pygmt-on-google-colab/898/8 "2021-01-14T20:25:30Z")

</div>

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![liamtoney](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/liamtoney/32/2021_2.png) [@liamtoney](https://forum.generic-mapping-tools.org/u/liamtoney)\
**Post date:** [February 10, 2021, 9:07pm UTC](https://forum.generic-mapping-tools.org/t/installing-pygmt-on-google-colab/898/9 "2021-02-10T21:07:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![seisman](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/seisman/32/4_2.png) [@seisman](https://forum.generic-mapping-tools.org/u/seisman)\
**Post date:** [February 10, 2021, 9:12pm UTC](https://forum.generic-mapping-tools.org/t/installing-pygmt-on-google-colab/898/10 "2021-02-10T21:12:10Z")

</div>

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)](https://github.com/GenericMappingTools/try-gmt/issues/15)).

---

<div class="post-metadata">

**Author:** ![emetdan](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/emetdan/32/936_2.png) [@emetdan](https://forum.generic-mapping-tools.org/u/emetdan)\
**Post date:** [February 11, 2021, 3:14pm UTC](https://forum.generic-mapping-tools.org/t/installing-pygmt-on-google-colab/898/11 "2021-02-11T15:14:54Z")

</div>

I have the same issue

---

<div class="post-metadata">

**Author:** ![andrebelem](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/andrebelem/32/1218_2.png) [@andrebelem](https://forum.generic-mapping-tools.org/u/andrebelem)\
**Post date:** [May 1, 2021, 1:44am UTC](https://forum.generic-mapping-tools.org/t/installing-pygmt-on-google-colab/898/12 "2021-05-01T01:44:38Z")

</div>

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

 ![image](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/5/5edd00aef1ecec718ebb516f5a898313237b449a.png)

Any help ?

---

<div class="post-metadata">

**Author:** ![emetdan](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/emetdan/32/936_2.png) [@emetdan](https://forum.generic-mapping-tools.org/u/emetdan)\
**Post date:** [August 10, 2021, 9:20pm UTC](https://forum.generic-mapping-tools.org/t/installing-pygmt-on-google-colab/898/13 "2021-08-10T21:20:03Z")

</div>

Solved here:

> [@COLAB example on github "Try PyGMT online" not working any more](https://flint.soest.hawaii.edu/t/colab-example-on-github-try-pygmt-online-not-working-any-more/1790/7):
>
> Worked ! The sequence was: (1) update VM colab !sudo apt update !sudo apt upgrade -y !sudo apt install -y build-essential cmake libcurl4-gnutls-dev libnetcdf-dev gdal-bin libgdal-dev libfftw3-dev libpcre3-dev liblapack-dev libblas-dev libglib2.0-dev ghostscript ghostscript-x graphicsmagick ffmpeg xdg-utils (2) Install gmt from github !git clone --depth 50 https://github.com/GenericMappingTools/gmt (3) make everthing ! !cmake /content/gmt (4) install !cmake --build . --target install …

---

<div class="post-metadata">

**Author:** ![seisman](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/seisman/32/4_2.png) [@seisman](https://forum.generic-mapping-tools.org/u/seisman)\
**Post date:** [December 31, 2022, 5:50am UTC](https://forum.generic-mapping-tools.org/t/installing-pygmt-on-google-colab/898/14 "2022-12-31T05:50:28Z")

</div>

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

> [@COLAB example on github "Try PyGMT online" not working any more](https://flint.soest.hawaii.edu/t/colab-example-on-github-try-pygmt-online-not-working-any-more/1790/11):
>
> For anyone who reads this post: Currently, the best and simplest solution is to install conda using [condacolab](https://github.com/conda-incubator/condacolab). Install conda!pip install -q condacolab import condacolab condacolab.install() Install PyGMT and its depenecies!mamba install pygmt Please refer to [https://github.com/conda-incubator/condacolab](https://github.com/conda-incubator/condacolab) and [https://github.com/GenericMappingTools/try-gmt/blob/master/python-demo.ipynb](https://github.com/GenericMappingTools/try-gmt/blob/master/python-demo.ipynb) for the detailed instructions.
