ModuleNotFoundError: No module named 'surprise'

Viewed 13752

I have installed scikit-surprise in Windows10.

C:\Users\Cosmos Lord>pip install scikit-surprise

Requirement already satisfied: scikit-surprise in c:\users\cosmos lord\appdata\roaming\python\python37\site-packages (1.1.0) Requirement already satisfied: joblib>=0.11 in c:\users\cosmos lord\appdata\roaming\python\python37\site-packages (from scikit-surprise) (0.14.0) Requirement already satisfied: numpy>=1.11.2 in c:\users\cosmos lord\appdata\roaming\python\python37\site-packages (from scikit-surprise) (1.17.2) Requirement already satisfied: scipy>=1.0.0 in c:\users\cosmos lord\appdata\roaming\python\python37\site-packages (from scikit-surprise) (1.3.1) Requirement already satisfied: six>=1.10.0 in c:\users\cosmos lord\appdata\roaming\python\python37\site-packages (from scikit-surprise) (1.12.0)

But I am still unable to import surprise module.

In Spyder3 kernel, the following error is shown:

import surprise

Traceback (most recent call last):

File "", line 1, in import surprise

ModuleNotFoundError: No module named 'surprise'

Whereas in IDLE(Python-32 bit), the following error is shown:

Traceback (most recent call last): File "C:/Users/Cosmos Lord/Documents/Flask Projects/New folder/aaa.py", line 1, in import surprise File "C:\Users\Cosmos Lord\AppData\Roaming\Python\Python37\site-packages\surprise__init__.py", line 3, in from .prediction_algorithms import AlgoBase File "C:\Users\Cosmos Lord\AppData\Roaming\Python\Python37\site-packages\surprise\prediction_algorithms__init__.py", line 23, in from .algo_base import AlgoBase File "C:\Users\Cosmos Lord\AppData\Roaming\Python\Python37\site-packages\surprise\prediction_algorithms\algo_base.py", line 10, in from .. import similarities as sims ImportError: cannot import name 'similarities' from 'surprise' (C:\Users\Cosmos Lord\AppData\Roaming\Python\Python37\site-packages\surprise__init__.py)

How do I import surprise? Any help would be much appreciated.

5 Answers

From within Spyder kernel (console), run pip install surprise

Then restart the kernel.

It solved the problem for me

try:

pip install numpy
pip install scikit-surprise

if your problem didn't solve, then use conda forge:

conda install -c conda-forge scikit-surprise

Welcome to Stackoverflow

Surprise uses Cython, which requires a C compiler to be installed on the system.

More about Cython

Installing Visual studio C++2014 could sovle this issue. Try installing Visual Studio on your machine.

I think it's because your current working environment and the environment the surprise module has been installed into are different.

If you are sure that you are in the right env, kindly change your IDE. I changed mine to Jupyterlab and everything started working correctly.

Related