ModuleNotFoundError: No module named 'surprise'

↘锁芯ラ 提交于 2021-01-20 09:20:19

问题


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.


回答1:


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

Then restart the kernel.

It solved the problem for me




回答2:


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.




回答3:


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




回答4:


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




回答5:


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.



来源:https://stackoverflow.com/questions/58397225/modulenotfounderror-no-module-named-surprise

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!