gimli-org / gimli

Geophysical Inversion and Modeling Library :earth_africa:
https://www.pygimli.org
Other
348 stars 131 forks source link

problem using pygimli=1.4.0 in google colab #539

Closed Chih-Hao-Kuo closed 2 months ago

Chih-Hao-Kuo commented 1 year ago

Problem description

After installing the current version of pygimili on google colab, I received an error message as follows.

!conda install -c gimli pygimli=1.4.0

import pygimli

ImportError                               Traceback (most recent call last)
[/usr/local/lib/python3.10/site-packages/pygimli/core/core.py](https://localhost:8080/#) in <module>
     10 try:
---> 11     from . import _pygimli_  # if it works: as pgcore, replace all _pygimli_
     12     # from . import _pygimli_ as pgcore  # if it works: as pgcore, replace all _pygimli_

ImportError: cannot import name '_pygimli_' from partially initialized module 'pygimli.core' (most likely due to a circular import) (/usr/local/lib/python3.10/site-packages/pygimli/core/__init__.py)

During handling of the above exception, another exception occurred:

ModuleNotFoundError                       Traceback (most recent call last)
3 frames
[/usr/local/lib/python3.10/site-packages/pygimli/core/core.py](https://localhost:8080/#) in <module>
     17     # print("did not find in-place pg core, try import pgcore")
     18     # import pgcore as _pygimli_
---> 19     import pgcore
     20     # from pgcore import _pygimli_  # check version compatibility
     21     from pgcore import *

ModuleNotFoundError: No module named 'pgcore'

Your environment

Please provide the output of print(pygimli.Report()) here. If that does not work, please give provide some additional information on your:

Operating system: Windows Python version: Python 3.10.10 pyGIMLi version: 1.4.0 Way of installation:conda

Steps to reproduce

After creating a Google Colab notebook, just follow the manual instructions.

!pip install -q condacolab
import condacolab
condacolab.install()

import condacolab
condacolab.check()
!conda install -c gimli pygimli=1.4.0

After typing import pygimli, you will see the error message

Expected behavior

we should not experience any error message

Actual behavior

error message as follows:


ImportError                               Traceback (most recent call last)
[/usr/local/lib/python3.10/site-packages/pygimli/core/core.py](https://localhost:8080/#) in <module>
     10 try:
---> 11     from . import _pygimli_  # if it works: as pgcore, replace all _pygimli_
     12     # from . import _pygimli_ as pgcore  # if it works: as pgcore, replace all _pygimli_

ImportError: cannot import name '_pygimli_' from partially initialized module 'pygimli.core' (most likely due to a circular import) (/usr/local/lib/python3.10/site-packages/pygimli/core/__init__.py)

During handling of the above exception, another exception occurred:

ModuleNotFoundError                       Traceback (most recent call last)
3 frames
[/usr/local/lib/python3.10/site-packages/pygimli/core/core.py](https://localhost:8080/#) in <module>
     17     # print("did not find in-place pg core, try import pgcore")
     18     # import pgcore as _pygimli_
---> 19     import pgcore
     20     # from pgcore import _pygimli_  # check version compatibility
     21     from pgcore import *

ModuleNotFoundError: No module named 'pgcore'

If possible, please add one or more labels to your issue, e.g. if you expect that your issue is rather a question than a problem with the code, please add the label "question".

halbmy commented 1 year ago

I can confirm the error. It seems like pgcore is installed correctly but apparently it is not. I guess I will have to build a special conda package with the matching numpy etc. like I did last time for Python 3.7.

Chih-Hao-Kuo commented 1 year ago

Thank you. Is there any alternative or workaround? Let me know your recommendations.

halbmy commented 1 year ago

I am afraid not. We will have to look at which package versions are installed and build a conda package for it. Of course this will change everytime Google updates the configuration.

Chih-Hao-Kuo commented 1 year ago

I see. Thanks for letting me know. Do you have any timeline as to when this problem is expected to get fixed?

halbmy commented 1 year ago

I was wrong. pgcore seems not to be installed correctly. There is only a pgcore.pth pointing to the pgcore-1.4.0-py3.10.egg but a folder pgcore holding an init file and the libgimli.so is missing. Any help from people with more insight into conda installation is appreciated.

halbmy commented 7 months ago

After noting that Google Colab (or rather condacolab) has switched to Mambaforge with Python 3.10 and numpy 1.23, I just gave it another try. It seems to install 190 (!) packages and seems to install pygimli properly (!ls -l /usr/local/lib/python3.10/site-packages/pygimli):

drwxr-xr-x  3 root root  4096 Nov 13 06:46 core
drwxr-xr-x  3 root root  4096 Nov 13 06:46 frameworks
-rw-rw-r--  2 root root 10318 Nov  9 15:59 __init__.py
drwxr-xr-x  3 root root  4096 Nov 13 06:47 math
drwxr-xr-x  3 root root  4096 Nov 13 06:46 meshtools
drwxr-xr-x 12 root root  4096 Nov 13 06:46 physics
drwxr-xr-x  2 root root  4096 Nov 13 06:47 __pycache__
drwxr-xr-x  3 root root  4096 Nov 13 06:46 solver
drwxr-xr-x  3 root root  4096 Nov 13 06:46 testing
drwxr-xr-x  3 root root  4096 Nov 13 06:46 utils
-rw-rw-r--  2 root root   497 Nov  9 16:04 _version.py
drwxr-xr-x  5 root root  4096 Nov 13 06:46 viewer

but not pgcore (!ls -l /usr/local/lib/python3.10/site-packages/pgcore)

ls: cannot access '/usr/local/lib/python3.10/site-packages/pgcore': No such file or directory

Both packages seem to be installed correctly (!mamba list):

pgcore                    1.4.0                    pypi_0    pypi
pygimli                   1.4.5                      py_0    gimli

but pgcore is not installed at all. Boost 1.80 is installed, but there is no np123py39 core package (yet).

Chih-Hao-Kuo commented 7 months ago

Dear Thomas,

   Thanks for the update.  I also gave another try in google colab

using Mamba to install pygimli package.

!pip install -q condacolab import condacolab condacolab.install() !mamba install -c gimli pygimli

After installation is complete, I checked if the following packages have been installed :

!mamba list

pygimli 1.4.5 py_0 gimli pgcore 1.4.0 pypi_0 pypi

But if I tried to import pygimli package , I still get the following error.

import pygimli


ImportError Traceback (most recent call last)

/usr/local/lib/python3.10/site-packages/pygimli/core/core.py https://localhost:8080/# in 10 try: ---> 11 from . import pygimli # if it works: as pgcore, replace all pygimli 12 # from . import pygimli as pgcore # if it works: as pgcore, replace all pygimli

ImportError: cannot import name 'pygimli' from partially initialized module 'pygimli.core' (most likely due to a circular import) (/usr/local/lib/python3.10/site-packages/pygimli/core/init.py)

During handling of the above exception, another exception occurred:

ModuleNotFoundError Traceback (most recent call last)


3 frames

/usr/local/lib/python3.10/site-packages/pygimli/core/core.py https://localhost:8080/# in 17 # print("did not find in-place pg core, try import pgcore") 18 # import pgcore as pygimli ---> 19 import pgcore 20 # from pgcore import pygimli # check version compatibility 21 from pgcore import *

ModuleNotFoundError: No module named 'pgcore'


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.

The error message shows that the pgcore module is still not installed properly.

Also, I tried to downgrade the python version to 3.8 but experienced an error with the installation of condacolab.

Thanks Chih

On Mon, Nov 13, 2023 at 2:59 PM Thomas Günther @.***> wrote:

After noting that Google Colab (or rather condacolab) has switched to Mambaforge with Python 3.10 and numpy 1.23, I just gave it another try. It seems to install 190 (!) packages and seems to install pygimli properly (!ls -l /usr/local/lib/python3.10/site-packages/pygimli):

drwxr-xr-x 3 root root 4096 Nov 13 06:46 core drwxr-xr-x 3 root root 4096 Nov 13 06:46 frameworks -rw-rw-r-- 2 root root 10318 Nov 9 15:59 init.py drwxr-xr-x 3 root root 4096 Nov 13 06:47 math drwxr-xr-x 3 root root 4096 Nov 13 06:46 meshtools drwxr-xr-x 12 root root 4096 Nov 13 06:46 physics drwxr-xr-x 2 root root 4096 Nov 13 06:47 pycache drwxr-xr-x 3 root root 4096 Nov 13 06:46 solver drwxr-xr-x 3 root root 4096 Nov 13 06:46 testing drwxr-xr-x 3 root root 4096 Nov 13 06:46 utils -rw-rw-r-- 2 root root 497 Nov 9 16:04 _version.py drwxr-xr-x 5 root root 4096 Nov 13 06:46 viewer

but not pgcore (!ls -l /usr/local/lib/python3.10/site-packages/pgcore)

ls: cannot access '/usr/local/lib/python3.10/site-packages/pgcore': No such file or directory

Both packages seem to be installed correctly (!mamba list):

pgcore 1.4.0 pypi_0 pypi pygimli 1.4.5 py_0 gimli

but pgcore is not installed at all. Both `

— Reply to this email directly, view it on GitHub https://github.com/gimli-org/gimli/issues/539#issuecomment-1807567718, or unsubscribe https://github.com/notifications/unsubscribe-auth/APZYLJUHKPKPQJFGR5BVPZDYEHALVAVCNFSM6AAAAAAYM7MBO2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBXGU3DONZRHA . You are receiving this because you authored the thread.Message ID: @.***>

halbmy commented 3 months ago

From version v1.5 (just out now) on, we support pip as alternative way for installation, at least for Linux and still in test mode. This in turn allows for running pyGIMLi on Google colab again, see instructions on https://www.pygimli.org/installation.html#pygimli-on-google-colab