Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pygmt import error on google colaboratory #17

Closed
liamtoney opened this issue Feb 17, 2021 · 7 comments · Fixed by #45
Closed

pygmt import error on google colaboratory #17

liamtoney opened this issue Feb 17, 2021 · 7 comments · Fixed by #45
Labels
bug Something isn't working

Comments

@liamtoney
Copy link
Member

After running the cell which installs conda etc. the import pygmt command fails with:

Screen Shot 2021-02-17 at 12 05 48 PM

@seisman
Copy link
Member

seisman commented 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.

@weiji14 weiji14 added the bug Something isn't working label Jun 6, 2021
@weiji14 weiji14 changed the title pygmt import error pygmt import error on google collaboratory Jun 6, 2021
@weiji14
Copy link
Member

weiji14 commented Jun 6, 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.

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.

@weiji14 weiji14 changed the title pygmt import error on google collaboratory pygmt import error on google colaboratory Jun 19, 2021
@andrebelem
Copy link

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
Copy link

I-Hamama commented 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
Copy link

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
Copy link

I-Hamama commented 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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants