PreferredAI / cornac

A Comparative Framework for Multimodal Recommender Systems
https://cornac.preferred.ai
Apache License 2.0
888 stars 144 forks source link

[ASK] ImportError: error while `import cornac` #648

Closed sishen closed 1 week ago

sishen commented 1 week ago

Description

I followed the contributors guide and would like to run the example. But I got the error follows.

(venv) dingding@DD-E-Book cornac % python examples/first_example.py 
Traceback (most recent call last):
  File "/Codes/cornac/examples/first_example.py", line 17, in <module>
    import cornac
  File "<frozen zipimport>", line 259, in load_module
  File "/Codes/cornac/venv/lib/python3.9/site-packages/cornac-2.2.2-py3.9-macosx-10.9-universal2.egg/cornac/__init__.py", line 16, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/Codes/cornac/venv/lib/python3.9/site-packages/cornac-2.2.2-py3.9-macosx-10.9-universal2.egg/cornac/data/__init__.py", line 18, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/Codes/cornac/venv/lib/python3.9/site-packages/cornac-2.2.2-py3.9-macosx-10.9-universal2.egg/cornac/data/text.py", line 27, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/Codes/cornac/venv/lib/python3.9/site-packages/cornac-2.2.2-py3.9-macosx-10.9-universal2.egg/cornac/utils/__init__.py", line 16, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/Codes/cornac/venv/lib/python3.9/site-packages/cornac-2.2.2-py3.9-macosx-10.9-universal2.egg/cornac/utils/common.py", line 21, in <module>
ImportError: cannot import name 'inplace_csr_row_normalize_l1' from 'cornac.utils.fast_sparse_funcs' (/Users/dingding/Library/Caches/Python-Eggs/cornac-2.2.2-py3.9-macosx-10.9-universal2.egg-tmp/cornac/utils/fast_sparse_funcs.cpython-39-darwin.so)

However, when I run the import in the python interactive shell, it did import.

(venv) dingding@DD-E-Book cornac % python
Python 3.9.6 (default, Aug  9 2024, 14:24:13) 
[Clang 16.0.0 (clang-1600.0.26.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from cornac.utils.fast_sparse_funcs import inplace_csr_row_normalize_l1
>>> inplace_csr_row_normalize_l1
<cyfunction inplace_csr_row_normalize_l1 at 0x11a523c70>

How can I resolve the problem? I have followed the instructions at #396 but it didn't work. Thanks for the help!

Other Comments

sishen commented 1 week ago

Found the reason because it's a Apple M1 MacBook. After reinstalled the python with the arm arch, it works.