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

Uploaded a working version of pygmt on colab #37

Closed

Conversation

andrebelem
Copy link

This version is 100% functional in colab with PyGMT version v0.5.0, Python 3.7.13 (default, Apr 24 2022) and GMT lib version 6.5.0.

This version is 100% functional in colab with PyGMT version v0.5.0, Python 3.7.13 (default, Apr 24 2022) and GMT lib version 6.5.0.
This version is 100% functional in colab with PyGMT version v0.5.0, Python 3.7.13 (default, Apr 24 2022) and GMT lib version 6.5.0.
@seisman
Copy link
Member

seisman commented Jun 26, 2022

This version is 100% functional in colab with PyGMT version v0.5.0, Python 3.7.13 (default, Apr 24 2022) and GMT lib version 6.5.0.

As I understand it, Google Colab only provides Python 3.7, but PyGMT requires Python>=3.8 since v0.6.0. Do you know any way to install newer Python versions in Google Colab? I've tried many times but failed.

@andrebelem
Copy link
Author

Every time I tried to change Python version, some problem happened. However, installing GMT as I did, and then pip install pygmt, works perfectly.

Maybe we should write a "Warning" that even though PyGMT requires Python>=3.8, it works fine with 3.7 as long as it doesn't conflict with some internal requirement. As far as I could test with simple things (maps, figures, XY, etc) it works perfectly and without restrictions.

@weiji14
Copy link
Member

weiji14 commented Jul 2, 2022

Related issues at googlecolab/colabtools#1422 and googlecolab/colabtools#2165. No timeline as to when Google Colab will use Python 3.8+ though :/

Did any of you manage to try the solutions at https://stackoverflow.com/questions/60775160/install-python-3-8-kernel-in-google-colaboratory?

@andrebelem
Copy link
Author

Hello @weiji14
The solution I found was to install GMT "along" with the default Python 3.7 from colab and it works! In fact, in my classes I use COLAB with students and I have been doing exercises with PyGMT. So far there are no conflicts. The only downside is the installation time of 6-8 minutes.

But again - GMT/PyGMT over Python 3.7 COLAB works perfectly with the recipe I gave.

Maybe, instead of trying to go through this Branch that requires Python 3.8, we can create a parallel one for anyone who wants to use PyGMT via COLAB. I don't know how many people fit into this, but for example, in my classes it's much more practical for students to use COLAB in the teaching lab.

@andrebelem
Copy link
Author

trying to understand what in the validator was wrong. I believe it is not patch related.

@weiji14
Copy link
Member

weiji14 commented Dec 29, 2022

Looks like Google Colab finally updated to Python 3.8 in googlecolab/colabtools#3246 🎉 Shall we revive this Pull Request?

@weiji14
Copy link
Member

weiji14 commented Dec 29, 2022

I tried running this code block:

!wget --quiet https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh
!chmod +x Mambaforge-Linux-x86_64.sh
!bash ./Mambaforge-Linux-x86_64.sh -bfp /usr/local
!mamba 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"

But am getting an error like so on import pygmt:

GMTCLibNotFoundError: Error loading GMT shared library at '/usr/local/lib/libgmt.so'.
/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /usr/local/lib/./libgdal.so.32)
Error loading GMT shared library at 'libgmt.so'.
libgmt.so: cannot open shared object file: No such file or directory

I had a look at https://stackoverflow.com/questions/23244418/set-ld-library-path-before-importing-in-python which suggested setting LD_LIBRARY_PATH but that didn't work. Also tried symlinking following https://askubuntu.com/questions/1418016/glibcxx-3-4-30-not-found-in-conda-environment but that failed too. Need to try something else.

@joa-quim
Copy link
Member

I know this one. GCC12 broke compatibility of libstdc++ and conda uses GCC12 to build GMT. So if GMT is called from some program (very likely Python) built with and older version of GCC that error occurs.

@seisman
Copy link
Member

seisman commented Dec 31, 2022

Superseded by #45.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants