Open patwanjau opened 2 years ago
What version of Cython are you running?
Seems that the issue stems from a slightly older version of Cython being incompatible with Python 3.10.1, I found reference to it in the Cython repo issues.
If there is an update to your version of Cython available, install that. Otherwise, there are some instructions in the linked issue around building the latest release of Cython from source.
Alternatively, if possible, try using Python < 3.10.1 (maybe 3.9)
What version of Cython are you running?
Seems that the issue stems from a slightly older version of Cython being incompatible with Python 3.10.1, I found reference to it in the Cython repo issues.
If there is an update to your version of Cython available, install that. Otherwise, there are some instructions in the linked issue around building the latest release of Cython from source.
Alternatively, if possible, try using Python < 3.10.1 (maybe 3.9)
I will attempt to install from source as downgrading Python is not an option at the moment.
I just realised that what you're downloading when you install Surprise may be a pre-compiled wheel, which would have been compiled with an older version of Cython.
Perhaps try this:
For the latest version, you can also clone the repo and build the source (you'll first need Cython and numpy):
pip install numpy cython git clone https://github.com/NicolasHug/surprise.git cd surprise python setup.py install
(from the README)
It should compile Surprise with the new version of Cython you have installed.
I hit the same issue. Python: python-3.10.2-1 from Arch Linux
scikit-surprise
from pip
within a venv:
(.venv) [piotr@andrad ...]$ python -c 'import surprise; print("surprise", surprise.__version__)'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File ".../.venv/lib/python3.10/site-packages/surprise/__init__.py", line 3, in <module>
from .prediction_algorithms import AlgoBase
File ".../.venv/lib/python3.10/site-packages/surprise/prediction_algorithms/__init__.py", line 30, in <module>
from .matrix_factorization import SVD
ImportError: .../.venv/lib/python3.10/site-packages/surprise/prediction_algorithms/matrix_factorization.cpython-310-x86_64-linux-gnu.so:
undefined symbol: _PyGen_Send
Then I did:
(.venv) [piotr@andrad ...]$ pip install numpy cython
(.venv) [piotr@andrad ...]$ git clone https://github.com/NicolasHug/surprise.git
(.venv) [piotr@andrad ...]$ cd surprise
(.venv) [piotr@andrad .../surprise]$ python setup.py install
After that I tried again:
(.venv) [piotr@andrad .../surprise]$ python -c 'import surprise; print("surprise", surprise.__version__)'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File ".../surprise/surprise/__init__.py", line 3, in <module>
from .prediction_algorithms import AlgoBase
File ".../surprise/surprise/prediction_algorithms/__init__.py", line 23, in <module>
from .algo_base import AlgoBase
File ".../surprise/surprise/prediction_algorithms/algo_base.py", line 10, in <module>
from .. import similarities as sims
ImportError: cannot import name 'similarities' from partially initialized module 'surprise' (most likely due to a circular import) (.../surprise/surprise/__init__.py)
(.venv) [piotr@andrad .../surprise]$ cd ..
(.venv) [piotr@andrad ...]$ python -c 'import surprise; print("surprise", surprise.__version__)'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File ".../.venv/lib/python3.10/site-packages/surprise/__init__.py", line 3, in <module>
from .prediction_algorithms import AlgoBase
File ".../.venv/lib/python3.10/site-packages/surprise/prediction_algorithms/__init__.py", line 30, in <module>
from .matrix_factorization import SVD
ImportError: .../.venv/lib/python3.10/site-packages/surprise/prediction_algorithms/matrix_factorization.cpython-310-x86_64-linux-gnu.so:
undefined symbol: _PyGen_Send
I don't think I understand the problem and I can't really dig deeper into it right now, but maybe someone more knowledgeable can make something out of it. Btw, this issue seems to be quite similar.
Recreating the venv with Python 3.9 (python39-3.9.11-3
from AUR) alleviated the issue.
(.venv) [piotr@andrad ...]$ python -c 'import surprise; print("surprise", surprise.__version__)'
surprise 1.1.1
We also had a problem with importing surprise
, but we discovered the issue was with numpy
version:
1.20.3
failed1.22.4
succeededSo it seems the numpy
requirement:
https://github.com/NicolasHug/Surprise/blob/46b9914995e6c8c7d227b46f2eaeef2d4600580f/requirements.txt#L2
is too loose and it should be more like numpy>=1.22
(or at least it should exclude version range around 1.20
)
Description
I am working on a recommender systems project and Surprise has been used as the preferred package in my examples. However, I'm experiencing problems when I use Surprise. There results in an import error attributed to the cpython library. Below is the error encountered:
Steps/Code to Reproduce
Expected Results
1.1.1
Actual Results
Versions
Linux-5.15.12-200.fc35.x86_64-x86_64-with-glibc2.34 Python 3.10.1 (main, Dec 9 2021, 00:00:00) [GCC 11.2.1 20211203 (Red Hat 11.2.1-7)]
Getting the version for surprise failed when executed in the code for "Steps to reproduce"