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

Error in installing pygimli in mac M1 #618

Open
makeabhishek opened this issue Nov 19, 2023 · 4 comments
Open

Error in installing pygimli in mac M1 #618

makeabhishek opened this issue Nov 19, 2023 · 4 comments
Assignees

Comments

@makeabhishek
Copy link

Problem description

Error in importing pygimli. I installed pygimli in mac m1 max, but importing pygimli is giving error. I also tried to install by CONDA_SUBDIR=osx-arm64 conda create -n pg -c gimli -c conda-forge pygimli=1.4.5 . But same issue

Your environment

Operating system: MacOS Monterey version 12.7.1
Chip Apple M1 Max
Python version: 3.11.6
pyGIMLi version: Output of print(pygimli.__version__)
NameError: name 'pygimli' is not defined

Way of installation: e.g. Conda package, manual compilation from source, etc.
conda create -n pg -c gimli -c conda-forge pygimli=1.4.

Installation goes successfull

Proceed ([y]/n)? y


Downloading and Extracting Packages

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate pg
#
# To deactivate an active environment, use
#
#     $ conda deactivate

Steps to reproduce

Tell us how to reproduce this issue. Ideally, you could paste the code that produces the error:

(pg) asaini@pn2301151 ~ % python -c "import pygimli; pygimli.test(show=False, onlydoctests=True)"
dlopen(/opt/anaconda3/envs/pg/lib/python3.11/site-packages/pgcore/_pygimli_.so, 0x0002): Library not loaded: '@rpath/libcholmod.3.dylib'
  Referenced from: '/opt/anaconda3/envs/pg/lib/libgimli.dylib'
  Reason: tried: '/opt/anaconda3/envs/pg/lib/libcholmod.3.dylib' (no such file), '/opt/anaconda3/envs/pg/lib/../lib64/libcholmod.3.dylib' (no such file), '/opt/anaconda3/envs/pg/lib/python3.11/site-packages/pgcore/../../../libcholmod.3.dylib' (no such file), '/opt/anaconda3/envs/pg/lib/python3.11/site-packages/pgcore/../../../../lib64/libcholmod.3.dylib' (no such file), '/opt/anaconda3/envs/pg/lib/python3.11/site-packages/pgcore/../../../libcholmod.3.dylib' (no such file), '/opt/anaconda3/envs/pg/lib/python3.11/site-packages/pgcore/../../../../lib64/libcholmod.3.dylib' (no such file), '/opt/anaconda3/envs/pg/bin/../lib/libcholmod.3.dylib' (no such file), '/opt/anaconda3/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)
Traceback (most recent call last):
  File "/opt/anaconda3/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) (/opt/anaconda3/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 "/opt/anaconda3/envs/pg/lib/python3.11/site-packages/pgcore/__init__.py", line 20, in <module>
    from ._pygimli_ import *
ImportError: dlopen(/opt/anaconda3/envs/pg/lib/python3.11/site-packages/pgcore/_pygimli_.so, 0x0002): Library not loaded: '@rpath/libcholmod.3.dylib'
  Referenced from: '/opt/anaconda3/envs/pg/lib/libgimli.dylib'
  Reason: tried: '/opt/anaconda3/envs/pg/lib/libcholmod.3.dylib' (no such file), '/opt/anaconda3/envs/pg/lib/../lib64/libcholmod.3.dylib' (no such file), '/opt/anaconda3/envs/pg/lib/python3.11/site-packages/pgcore/../../../libcholmod.3.dylib' (no such file), '/opt/anaconda3/envs/pg/lib/python3.11/site-packages/pgcore/../../../../lib64/libcholmod.3.dylib' (no such file), '/opt/anaconda3/envs/pg/lib/python3.11/site-packages/pgcore/../../../libcholmod.3.dylib' (no such file), '/opt/anaconda3/envs/pg/lib/python3.11/site-packages/pgcore/../../../../lib64/libcholmod.3.dylib' (no such file), '/opt/anaconda3/envs/pg/bin/../lib/libcholmod.3.dylib' (no such file), '/opt/anaconda3/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)
ERROR: cannot import the library '_pygimli_'.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/anaconda3/envs/pg/lib/python3.11/site-packages/pygimli/__init__.py", line 8, in <module>
    from .core.decorators import (renamed, singleton, moduleProperty,
  File "/opt/anaconda3/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 "/opt/anaconda3/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' (/opt/anaconda3/envs/pg/lib/python3.11/site-packages/pygimli/core/core.py)
(pg) asaini@pn2301151 ~ % 
...
@florian-wagner florian-wagner self-assigned this Nov 21, 2023
@florian-wagner
Copy link
Member

Dear @makeabhishek,

can you please try with pygimli 1.4.6 again?

Best wishes for the new year
Florian

@makeabhishek
Copy link
Author

makeabhishek commented Jan 21, 2024

Dear @florian-wagner

Tried to install but still getting following error.

Verifying transaction: done                                                     
Executing transaction: done                                                                                                
                                                                            
(base) asaini@pn2301151 ~ % conda activate pg
(pg) asaini@pn2301151 ~ % python -c "import pygimli; pygimli.test(show=False, onlydoctests=True)"  
dlopen(/opt/anaconda3/envs/pg/lib/python3.11/site-packages/pgcore/_pygimli_.so, 0x0002): Library not loaded: '@rpath/libcholmod.3.dylib'
  Referenced from: '/opt/anaconda3/envs/pg/lib/libgimli.dylib'
  Reason: tried: '/opt/anaconda3/envs/pg/lib/libcholmod.3.dylib' (no such file), '/opt/anaconda3/envs/pg/lib/../lib64/libcholmod.3.dylib' (no such file), '/opt/anaconda3/envs/pg/lib/python3.11/site-packages/pgcore/../../../libcholmod.3.dylib' (no such file), '/opt/anaconda3/envs/pg/lib/python3.11/site-packages/pgcore/../../../../lib64/libcholmod.3.dylib' (no such file), '/opt/anaconda3/envs/pg/lib/python3.11/site-packages/pgcore/../../../libcholmod.3.dylib' (no such file), '/opt/anaconda3/envs/pg/lib/python3.11/site-packages/pgcore/../../../../lib64/libcholmod.3.dylib' (no such file), '/opt/anaconda3/envs/pg/bin/../lib/libcholmod.3.dylib' (no such file), '/opt/anaconda3/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)
Traceback (most recent call last):
  File "/opt/anaconda3/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) (/opt/anaconda3/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 "/opt/anaconda3/envs/pg/lib/python3.11/site-packages/pgcore/__init__.py", line 20, in <module>
    from ._pygimli_ import *
ImportError: dlopen(/opt/anaconda3/envs/pg/lib/python3.11/site-packages/pgcore/_pygimli_.so, 0x0002): Library not loaded: '@rpath/libcholmod.3.dylib'
  Referenced from: '/opt/anaconda3/envs/pg/lib/libgimli.dylib'
  Reason: tried: '/opt/anaconda3/envs/pg/lib/libcholmod.3.dylib' (no such file), '/opt/anaconda3/envs/pg/lib/../lib64/libcholmod.3.dylib' (no such file), '/opt/anaconda3/envs/pg/lib/python3.11/site-packages/pgcore/../../../libcholmod.3.dylib' (no such file), '/opt/anaconda3/envs/pg/lib/python3.11/site-packages/pgcore/../../../../lib64/libcholmod.3.dylib' (no such file), '/opt/anaconda3/envs/pg/lib/python3.11/site-packages/pgcore/../../../libcholmod.3.dylib' (no such file), '/opt/anaconda3/envs/pg/lib/python3.11/site-packages/pgcore/../../../../lib64/libcholmod.3.dylib' (no such file), '/opt/anaconda3/envs/pg/bin/../lib/libcholmod.3.dylib' (no such file), '/opt/anaconda3/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)
ERROR: cannot import the library '_pygimli_'.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/anaconda3/envs/pg/lib/python3.11/site-packages/pygimli/__init__.py", line 8, in <module>
    from .core.decorators import (renamed, singleton, moduleProperty,
  File "/opt/anaconda3/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 "/opt/anaconda3/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' (/opt/anaconda3/envs/pg/lib/python3.11/site-packages/pygimli/core/core.py)

@ruboerner
Copy link

I just had the same issue on an M3 Macbook.

pygimli tries to load shared libraries, like, e.g., libcholmod.3.dylib and libumfpack.5.dylib, but can't find them (no such file).

I inspected the directory where the libraries are installed. In my case there have been newer version than those expected by pygimli. I solved the problem by adding symbolic links pointing to the already installed versions.

Example:

In the directory $HOME/miniconda3/envs/pg/lib (adapt the path to your specific case) do the following:

Note the release of the installed libraries:

ls -l libumfpack.*.dylib

Look for, e.g., libumfpack.6.0.1.dylib, then make a symbolic link to the version required by pygimli (which is the missing file in the runtime error message).
So, if 'libumfpack.5.dylib' is not found, but version 6.0.1 is available, then type

ln -s libumfpack.6.0.1.dylib libumfpack.5.dylib

Repeat these steps for libcholmod.*.dylib

This has solved my problem in some brute-force manner. The reason seems to be a side effect from some other packages' requirements.

Cheers,
Ralph

@florian-wagner
Copy link
Member

Dear @ruboerner,

thank you for the valuable feedback. Hardlinking to specific versions of umfpack and cholmod should not be necessary. We have have to fix this from our side.

And: Congratulations on the M3!

Florian

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

No branches or pull requests

4 participants