gimli-org / gimli

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

Can't import RVector3 when installing package #772

Closed gabrahamastro closed 1 month ago

gabrahamastro commented 1 month ago

Problem

Having created the conda environment pg on Spyder as instructed by the installation instructions, when in the pg environment and trying to run the code import pygimli as pg an error comes up which reads cannot import name 'RVector3' from 'pygimli.core.core'

Background

Operating system: MacOS 15.0 (x86_64) Python version: 3.11.9 pyGIMLi version: 1.5.1 Sypder version: 6.0.1 Way of installation: Using conda

Steps to reproduce

I entered the pg conda environment by changing the default environment in the Consoles tab, before entering the below after having entered IPython automatically.

import pygimli as @@#pg

Expected behavior

This should import the package, with no error responses.

Actual behaviour

The package was not imported correctly, with the following output being generated:

import pygimli as pg
dlopen(/usr/local/Caskroom/miniforge/base/envs/pg/lib/python3.11/site-packages/pgcore/_pygimli_.so, 0x0002): Library not loaded: @rpath/libcholmod.3.dylib
  Referenced from: <8BABB57D-C0D2-33CC-9CFC-A1CCDED6DA32> /usr/local/Caskroom/miniforge/base/envs/pg/lib/libgimli.dylib
  Reason: tried: '/usr/local/Caskroom/miniforge/base/envs/pg/lib/libcholmod.3.dylib' (no such file), '/usr/local/Caskroom/miniforge/base/envs/pg/lib/../lib64/libcholmod.3.dylib' (no such file), '/usr/local/Caskroom/miniforge/base/envs/pg/lib/python3.11/site-packages/pgcore/../../../libcholmod.3.dylib' (no such file), '/usr/local/Caskroom/miniforge/base/envs/pg/lib/python3.11/site-packages/pgcore/../../../../lib64/libcholmod.3.dylib' (no such file), '/usr/local/Caskroom/miniforge/base/envs/pg/lib/python3.11/site-packages/pgcore/../../../libcholmod.3.dylib' (no such file), '/usr/local/Caskroom/miniforge/base/envs/pg/lib/python3.11/site-packages/pgcore/../../../../lib64/libcholmod.3.dylib' (no such file), '/usr/local/Caskroom/miniforge/base/envs/pg/bin/../lib/libcholmod.3.dylib' (no such file), '/usr/local/Caskroom/miniforge/base/envs/pg/bin/../lib/libcholmod.3.dylib' (no such file), '/usr/local/lib/libcholmod.3.dylib' (no such file), '/usr/lib/libcholmod.3.dylib' (no such file, not in dyld cache)
Traceback (most recent call last):
  File "/usr/local/Caskroom/miniforge/base/envs/pg/lib/python3.11/site-packages/pygimli/core/core.py", line 11, in <module>
    from . import _pygimli_  # 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/Caskroom/miniforge/base/envs/pg/lib/python3.11/site-packages/pygimli/core/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/Caskroom/miniforge/base/envs/pg/lib/python3.11/site-packages/pgcore/__init__.py", line 20, in <module>
    from ._pygimli_ import *
ImportError: dlopen(/usr/local/Caskroom/miniforge/base/envs/pg/lib/python3.11/site-packages/pgcore/_pygimli_.so, 0x0002): Library not loaded: @rpath/libcholmod.3.dylib
  Referenced from: <8BABB57D-C0D2-33CC-9CFC-A1CCDED6DA32> /usr/local/Caskroom/miniforge/base/envs/pg/lib/libgimli.dylib
  Reason: tried: '/usr/local/Caskroom/miniforge/base/envs/pg/lib/libcholmod.3.dylib' (no such file), '/usr/local/Caskroom/miniforge/base/envs/pg/lib/../lib64/libcholmod.3.dylib' (no such file), '/usr/local/Caskroom/miniforge/base/envs/pg/lib/python3.11/site-packages/pgcore/../../../libcholmod.3.dylib' (no such file), '/usr/local/Caskroom/miniforge/base/envs/pg/lib/python3.11/site-packages/pgcore/../../../../lib64/libcholmod.3.dylib' (no such file), '/usr/local/Caskroom/miniforge/base/envs/pg/lib/python3.11/site-packages/pgcore/../../../libcholmod.3.dylib' (no such file), '/usr/local/Caskroom/miniforge/base/envs/pg/lib/python3.11/site-packages/pgcore/../../../../lib64/libcholmod.3.dylib' (no such file), '/usr/local/Caskroom/miniforge/base/envs/pg/bin/../lib/libcholmod.3.dylib' (no such file), '/usr/local/Caskroom/miniforge/base/envs/pg/bin/../lib/libcholmod.3.dylib' (no such file), '/usr/local/lib/libcholmod.3.dylib' (no such file), '/usr/lib/libcholmod.3.dylib' (no such file, not in dyld cache)
ERROR: cannot import the library '_pygimli_'.
Traceback (most recent call last):

  Cell In[1], line 1
    import pygimli as pg

  File /usr/local/Caskroom/miniforge/base/envs/pg/lib/python3.11/site-packages/pygimli/__init__.py:8
    from .core.decorators import (renamed, singleton, moduleProperty,

  File /usr/local/Caskroom/miniforge/base/envs/pg/lib/python3.11/site-packages/pygimli/core/__init__.py:14
    from .base import (isInt, isScalar, isIterable, isArray, isPos, isR3Array,

  File /usr/local/Caskroom/miniforge/base/envs/pg/lib/python3.11/site-packages/pygimli/core/base.py:7
    from .core import (RVector3, R3Vector, RMatrix)

ImportError: cannot import name 'RVector3' from 'pygimli.core.core' (/usr/local/Caskroom/miniforge/base/envs/pg/lib/python3.11/site-packages/pygimli/core/core.py)
halbmy commented 1 month ago

This is related to an incompatible suitesparse version. Please have a look at #761 and the solution given there.

gabrahamastro commented 1 month ago

When running the below in terminal as per #761 before retrying in Spyder, it worked perfectly - thank you @halbmy! conda create -n pg -c gimli -c conda-forge "pygimli>=1.5.0" python=3.10 suitesparse=5