question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Import issue on Mac M1

See original GitHub issue

Describe the bug import cdlib.algorithms Apple M1 chip

(dynamo-dev) Ks-MacBook-Pro:dynamo-tutorials random$ python
Python 3.9.7 (default, Sep 16 2021, 08:50:36) 
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cdlib
>>> import cdlib.algorithms
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/random/opt/anaconda3/envs/dynamo-dev/lib/python3.9/site-packages/cdlib/algorithms/__init__.py", line 2, in <module>
    from .crisp_partition import *
  File "/Users/random/opt/anaconda3/envs/dynamo-dev/lib/python3.9/site-packages/cdlib/algorithms/crisp_partition.py", line 2, in <module>
    import infomap as imp
  File "/Users/random/opt/anaconda3/envs/dynamo-dev/lib/python3.9/site-packages/infomap.py", line 35, in <module>
    import _infomap
ImportError: dlopen(/Users/random/opt/anaconda3/envs/dynamo-dev/lib/python3.9/site-packages/_infomap.cpython-39-darwin.so, 0x0002): Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib
  Referenced from: /Users/random/opt/anaconda3/envs/dynamo-dev/lib/python3.9/site-packages/_infomap.cpython-39-darwin.so
  Reason: tried: '/usr/local/opt/libomp/lib/libomp.dylib' (no such file), '/usr/local/lib/libomp.dylib' (no such file), '/usr/lib/libomp.dylib' (no such file)
(cdlib-test) Ks-MacBook-Pro:16725-medical-imaging random$ python
Python 3.8.12 | packaged by conda-forge | (default, Jan 30 2022, 23:36:06) 
[Clang 11.1.0 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cdlib
>>> import cdlib.algorithms
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/random/opt/anaconda3/envs/cdlib-test/lib/python3.8/site-packages/cdlib/algorithms/__init__.py", line 2, in <module>
    from .crisp_partition import *
  File "/Users/random/opt/anaconda3/envs/cdlib-test/lib/python3.8/site-packages/cdlib/algorithms/crisp_partition.py", line 2, in <module>
    import infomap as imp
  File "/Users/random/opt/anaconda3/envs/cdlib-test/lib/python3.8/site-packages/infomap.py", line 35, in <module>
    import _infomap
ImportError: dlopen(/Users/random/opt/anaconda3/envs/cdlib-test/lib/python3.8/site-packages/_infomap.cpython-38-darwin.so, 0x0002): Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib
  Referenced from: /Users/random/opt/anaconda3/envs/cdlib-test/lib/python3.8/site-packages/_infomap.cpython-38-darwin.so
  Reason: tried: '/usr/local/opt/libomp/lib/libomp.dylib' (no such file), '/usr/local/lib/libomp.dylib' (no such file), '/usr/lib/libomp.dylib' (no such file)

To Reproduce installed via pip

Name: cdlib
Version: 0.2.5
Summary: Community Discovery Library
Home-page: https://github.com/GiulioRossetti/cdlib
Author: Giulio Rossetti
Author-email: giulio.rossetti@gmail.com
License: BSD-Clause-2
Location: /Users/random/opt/anaconda3/envs/cdlib-test/lib/python3.8/site-packages
Requires: angel-cd, bimlpa, chinese-whispers, cython, demon, dynetx, eva-lcd, future, infomap, karateclub, leidenalg, markov-clustering, matplotlib, networkx, nf1, numpy, pandas, pooch, pulp, pyclustering, python-igraph, python-Levenshtein, python-louvain, scikit-learn, scipy, seaborn, thresholdclustering, tqdm, wurlitzer
  • Operating System
    • macOS Monterey
  • Python version
  • tried in conda env 3.7, 3.8, 3.9

Expected behavior Import successfully (cdlib worked and tested in 2021)

I treid brew install libomp but it does not work. The laptop is relatively new (released last year) and there are almost no messy system level customizations on this laptop.

Thanks for providing the community with the package! It is convenient, powerful and with good documentation.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Yquetzalcommented, Mar 17, 2022

@dummyindex Following your problem, we modified the library structure so that you are not blocked by external packages that cannot install on your architecture. So now cdlib should work, you just cannot use infomap. I reported the problem to infomap managers, if you need it you can go to their GitHub and see that current workaround they propose, hopefully there is a simpler solution soon. Feel free to report any additional issue.

0reactions
GiulioRossetticommented, Mar 1, 2022

@Yquetzal I think that having a “light” version of CDlib should be easy to achieve (we already have something similar with the pip package). If you can spot all the “troubling” dependencies I’ll take care of revising the packaging pipeline and updating the installation instructions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python import error on M1 Mac Big Sur #9426 - GitHub
I'm running an M1 Mac with Big Sur 11.4. I followed the installation steps at https://dev.intelrealsense.com/docs/macos-installation-for-intel- ...
Read more >
Cannot import TensorFlow on Mac M1 - Apple Developer
I'm trying to run a shell script on Mac OS M1, but it keeps giving me the error: ModuleNotFoundError: No module named 'tensorflow'....
Read more >
How can I fix error importing numpy in a Jupyter notebook on ...
I tried to import numpy in a Jupyter notebook file but it showed the following error (it's completely normal if I import numpy...
Read more >
Solved: videos won't play on MacBook Pro with M1 Max chip
After some trial and error, I found the problem was from using Image Capture to import my videos from the GoPro camera. For...
Read more >
Import issue with the AVID on M1 mac : r/editors - Reddit
I've been trying it out and I've immediately run into an issue: I can't seem to import footage.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found