gimli-org / gimli

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

Cannot import name 'RVector3' form 'pygimli.core.core #721

Open schaatz opened 5 months ago

schaatz commented 5 months ago

Problem description

When I import pygimli, it showed "cannot import name 'RVector3' form 'pygimli.core.core'".

Your environment

Operating system: Linux Python version: 3.11.9 pyGIMLi version: 1.5.1 Way of installation:Conda package

Steps to reproduce

When I try to run a Python file, I encounter this error, "cannot import name 'RVector3' form 'pygimli.core.core'", but on my Windows system with the same Python and PyGIMLi versions, it doesn't throw an error.

Expected behavior

No wrong information

Actual behavior

cannot import name 'RVector3' form 'pygimli.core.core'

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".

siarw commented 5 months ago

I am having the same problem, but my output has earlier errors. I appreciate any help.

OS: macOS 14.5 (23F79) Python: 3.11.9 PyGIMLi: pygimli-1.5.1 Installed using: conda

Here's the output.

/Users/pedro/miniconda3/envs/pg/bin/python /Users/pedro/Documents/Geophysics/tutorial1.py
dlopen(/Users/pedro/miniconda3/envs/pg/lib/python3.11/site-packages/pgcore/_pygimli_.so, 0x0002): Library not loaded: @rpath/libcholmod.3.dylib
  Referenced from: <D05C48BA-33ED-3C63-8331-F97D57235C73> /Users/pedro/miniconda3/envs/pg/lib/libgimli.dylib
  Reason: tried: '/Users/pedro/miniconda3/envs/pg/lib/libcholmod.3.dylib' (no such file), '/Users/pedro/miniconda3/envs/pg/lib/../lib64/libcholmod.3.dylib' (no such file), '/Users/pedro/miniconda3/envs/pg/lib/python3.11/site-packages/pgcore/../../../libcholmod.3.dylib' (no such file), '/Users/pedro/miniconda3/envs/pg/lib/python3.11/site-packages/pgcore/../../../../lib64/libcholmod.3.dylib' (no such file), '/Users/pedro/miniconda3/envs/pg/lib/python3.11/site-packages/pgcore/../../../libcholmod.3.dylib' (no such file), '/Users/pedro/miniconda3/envs/pg/lib/python3.11/site-packages/pgcore/../../../../lib64/libcholmod.3.dylib' (no such file), '/Users/pedro/miniconda3/envs/pg/bin/../lib/libcholmod.3.dylib' (no such file), '/Users/pedro/miniconda3/envs/pg/bin/../lib/libcholmod.3.dylib' (no such file)
Traceback (most recent call last):
  File "/Users/pedro/miniconda3/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) (/Users/pedro/miniconda3/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 "/Users/pedro/miniconda3/envs/pg/lib/python3.11/site-packages/pgcore/__init__.py", line 20, in <module>
    from ._pygimli_ import *
ImportError: dlopen(/Users/pedro/miniconda3/envs/pg/lib/python3.11/site-packages/pgcore/_pygimli_.so, 0x0002): Library not loaded: @rpath/libcholmod.3.dylib
  Referenced from: <D05C48BA-33ED-3C63-8331-F97D57235C73> /Users/pedro/miniconda3/envs/pg/lib/libgimli.dylib
  Reason: tried: '/Users/pedro/miniconda3/envs/pg/lib/libcholmod.3.dylib' (no such file), '/Users/pedro/miniconda3/envs/pg/lib/../lib64/libcholmod.3.dylib' (no such file), '/Users/pedro/miniconda3/envs/pg/lib/python3.11/site-packages/pgcore/../../../libcholmod.3.dylib' (no such file), '/Users/pedro/miniconda3/envs/pg/lib/python3.11/site-packages/pgcore/../../../../lib64/libcholmod.3.dylib' (no such file), '/Users/pedro/miniconda3/envs/pg/lib/python3.11/site-packages/pgcore/../../../libcholmod.3.dylib' (no such file), '/Users/pedro/miniconda3/envs/pg/lib/python3.11/site-packages/pgcore/../../../../lib64/libcholmod.3.dylib' (no such file), '/Users/pedro/miniconda3/envs/pg/bin/../lib/libcholmod.3.dylib' (no such file), '/Users/pedro/miniconda3/envs/pg/bin/../lib/libcholmod.3.dylib' (no such file)
ERROR: cannot import the library '_pygimli_'.
Traceback (most recent call last):
  File "/Users/pedro/Documents/Geophysics/tutorial1.py", line 1, in <module>
    import pygimli as pg
  File "/Users/pedro/miniconda3/envs/pg/lib/python3.11/site-packages/pygimli/__init__.py", line 8, in <module>
    from .core.decorators import (renamed, singleton, moduleProperty,
  File "/Users/pedro/miniconda3/envs/pg/lib/python3.11/site-packages/pygimli/core/__init__.py", line 14, in <module>
    from .base import (isInt, isScalar, isIterable, isArray, isPos, isR3Array,
  File "/Users/pedro/miniconda3/envs/pg/lib/python3.11/site-packages/pygimli/core/base.py", line 7, in <module>
    from .core import (RVector3, R3Vector, RMatrix)
ImportError: cannot import name 'RVector3' from 'pygimli.core.core' (/Users/pedro/miniconda3/envs/pg/lib/python3.11/site-packages/pygimli/core/core.py)
ruboerner commented 5 months ago

I encountered a similar problem after installing pygimli-1.5.1 in a fresh environment on a Mac. To solve the problem I had to provide symbolic links in the lib folder of the environment.

More precisely:

Go to the folder where the libraries are:

cd /Users/xxx/miniconda3/envs/pg/lib

Create the following symbolic links

ln -s libcholmod.5.dylib libcholmod.3.dylib
ln -s libumfpack.6.dylib libumfpack.5.dylib

Hope this helps!

Cheers, Ralph

halbmy commented 5 months ago

Obviously we have to change our conda recipies to make sure the runtime versions match the build versions.

halbmy commented 5 months ago

We should also avoid the strange error message about RVector3 and provide an error message that links users back to the installation problems.

siarw commented 5 months ago

I encountered a similar problem after installing pygimli-1.5.1 in a fresh environment on a Mac. To solve the problem I had to provide symbolic links in the lib folder of the environment.

More precisely:

Go to the folder where the libraries are:

cd /Users/xxx/miniconda3/envs/pg/lib

Create the following symbolic links

ln -s libcholmod.5.dylib libcholmod.3.dylib
ln -s libumfpack.6.dylib libumfpack.5.dylib

Hope this helps!

Cheers, Ralph

This solved it. Many thanks, Ralph @ruboerner !

halbmy commented 5 months ago

Linkage might not be the solution as shown by #721.

Can you try explicitly specifying suitesparse versions? UMFPACK 5 is probably related to suitesparse 6, so maybe adding suitesparse=6 to the install command?

dtiger10 commented 1 week ago

I encountered a similar problem after installing pygimli-1.5.1 in a fresh environment on a Mac. To solve the problem I had to provide symbolic links in the lib folder of the environment. More precisely: Go to the folder where the libraries are:

cd /Users/xxx/miniconda3/envs/pg/lib

Create the following symbolic links

ln -s libcholmod.5.dylib libcholmod.3.dylib
ln -s libumfpack.6.dylib libumfpack.5.dylib

Hope this helps! Cheers, Ralph

This solved it. Many thanks, Ralph @ruboerner !

Hello @siarw,

I am running into the exact issue. However I simply implemented the directions above AND my installation still outputs the error that you displayed. Did you do anything beyond initiating those two lines of code in the ./pg/lib/ directory?

Any insight would be appreciative...

Best, Del