Pygmt in google colab

Hi

My preferred form of working with pygmt has been on google colab, though I have been encountering problems since the latest updates.

It seems it has to do with the numpy versions, but I do have the newest version of it. In spite of that, I used the ‘numpy.version’ command right after importing numpy, and it seems that colab imports version 1.26.0, even though the latest versions are 2.2.0 or above. I tried to follow some steps I found online to have an environment in my google drive, and then load it, but to no success.

For what I understand, pygmt also imports numpy on its own, but I’m not sure what that data flow is like.

The following error message and screenshot are from the very colab notebook “python-demo-google-colab.ipynb”

I hope you can help me use it with colab again!
Thanks in advance

Regards,
Iván

ModuleNotFoundError Traceback (most recent call last)

in <cell line: 0>()
1 # Load the PyGMT package. This only needs to be run once
----> 2 import pygmt

9 frames

/usr/local/lib/python3.11/site-packages/xarray/core/nputils.py in
14 # remove once numpy 2.0 is the oldest supported version
15 if module_available(“numpy”, minversion=“2.0.0.dev0”):
—> 16 from numpy.lib.array_utils import ( # type: ignore[import-not-found,unused-ignore]
17 normalize_axis_index,
18 )

ModuleNotFoundError: No module named ‘numpy.lib.array_utils’

Dear GMT Community Forum Users

I am having the same issue with pygmt and Colab.

Someone know how to solve?

ModuleNotFoundError Traceback (most recent call last)

in <cell line: 0>() ----> 1 import pygmt


9 frames

/usr/local/lib/python3.11/site-packages/xarray/core/nputils.py in 14 # remove once numpy 2.0 is the oldest supported version 15 if module_available(“numpy”, minversion=“2.0.0.dev0”): —> 16 from numpy.lib.array_utils import ( # type: ignore[import-not-found,unused-ignore] 17 normalize_axis_index, 18 )

ModuleNotFoundError: No module named ‘numpy.lib.array_utils’

--------------------------------------------------------------------------- NOTE: If your import is failing due to a missing package, you can manually install dependencies using either !pip or !apt. To view examples of installing some common dependencies, click the “Open Examples” button below.

Best regards