Surprise icon indicating copy to clipboard operation
Surprise copied to clipboard

CANNOT IMPORT 'SIMILARITIES '

Open williamwei2 opened this issue 5 years ago • 13 comments

Hi, I feel stuck in the installing process of using surprise pakage under Colab.google.research framewrok, the details is going like this:

  1. copy the repository

INPUT: !git clone https://github.com/NicolasHug/surprise.git OUTPUT: Cloning into 'surprise'... remote: Enumerating objects: 36, done. remote: Counting objects: 100% (36/36), done. remote: Compressing objects: 100% (30/30), done. remote: Total 4257 (delta 10), reused 14 (delta 6), pack-reused 4221 Receiving objects: 100% (4257/4257), 6.36 MiB | 5.03 MiB/s, done. Resolving deltas: 100% (2964/2964), done.

  1. locate the corresondig file INPUT: cd surprise OUTPUT: /content/surprise

3.Install INPUT !python setup.py install OUTPUT (TOO LONG , SO IGNORE DESCRIPITION ABOUT ADDING FILES)

4.import package INPUT: import pandas as pd from surprise import Reader from surprise import Dataset from surprise.model_selection import cross_validate from surprise import NormalPredictor from surprise import KNNBasic from surprise import KNNWithMeans from surprise import KNNWithZScore from surprise import KNNBaseline from surprise import SVD from surprise import BaselineOnly from surprise import SVDpp from surprise import NMF from surprise import SlopeOne from surprise import CoClustering from surprise.accuracy import rmse from surprise import accuracy from surprise.model_selection import train_test_split

OUTPUT ImportError Traceback (most recent call last) in () 1 import pandas as pd ----> 2 from surprise import Reader 3 from surprise import Dataset 4 from surprise.model_selection import cross_validate 5 from surprise import NormalPredictor

2 frames /content/surprise/surprise/prediction_algorithms/algo_base.py in () 8 unicode_literals) 9 ---> 10 from .. import similarities as sims 11 from .predictions import PredictionImpossible 12 from .predictions import Prediction

ImportError: cannot import name 'similarities'

ANYONE COULD HELP THIS ?

THANKS IN ADVANCE

williamwei2 avatar Feb 13 '20 08:02 williamwei2

did something go wrong during the installation?

NicolasHug avatar Feb 13 '20 13:02 NicolasHug

Yup. It leaves an 'cannot import error' about the similarities class when I try to import the surprise package in colabsearch.google environment, a Linux environment.

---Original--- From: "Nicolas Hug"<[email protected]> Date: Thu, Feb 13, 2020 21:06 PM To: "NicolasHug/Surprise"<[email protected]>; Cc: "Author"<[email protected]>;"williamwei2"<[email protected]>; Subject: Re: [NicolasHug/Surprise] CANNOT IMPORT 'SIMILARITIES ' (#336)

did something go wrong during the installation?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

williamwei2 avatar Feb 13 '20 13:02 williamwei2

nothing goes wrong during installation

---Original--- From: "Nicolas Hug"<[email protected]> Date: Thu, Feb 13, 2020 21:06 PM To: "NicolasHug/Surprise"<[email protected]>; Cc: "Author"<[email protected]>;"williamwei2"<[email protected]>; Subject: Re: [NicolasHug/Surprise] CANNOT IMPORT 'SIMILARITIES ' (#336)

did something go wrong during the installation?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

williamwei2 avatar Feb 13 '20 13:02 williamwei2

have you properly followed the install from source instructions? If yes, please paste the entire log with installation details

NicolasHug avatar Feb 13 '20 14:02 NicolasHug

I think so. Could you please verify this. The log file is attached.

------------------ 原始邮件 ------------------ 发件人: "Nicolas Hug"<[email protected]>; 发送时间: 2020年2月13日(星期四) 晚上10:09 收件人: "NicolasHug/Surprise"<[email protected]>; 抄送: "691260559"<[email protected]>;"Author"<[email protected]>; 主题: Re: [NicolasHug/Surprise] CANNOT IMPORT 'SIMILARITIES ' (#336)

have you properly followed the install from source instructions? If yes, please paste the entire log with installation details

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

williamwei2 avatar Feb 13 '20 14:02 williamwei2

You probably attached it as email attachment. paste it on github instead pleae

NicolasHug avatar Feb 13 '20 14:02 NicolasHug

indeed it seems like it goes normally. Sorry I'm not sure I can help here. I think there are past discussions about using colab, you might have better luck there.

It's not possible to use conda or pip from within colab?

NicolasHug avatar Feb 13 '20 15:02 NicolasHug

Yeah, it could use pip or !pip, however, an unknown error would be incurred, as is followed: pip setup.py install ERROR: unknown command "setup.py" unkown error

williamwei2 avatar Feb 14 '20 02:02 williamwei2

Using Python instead of pip would be working to next line

williamwei2 avatar Feb 14 '20 02:02 williamwei2

Anyway , thx a lot, i will try to find colab topic anywhere

williamwei2 avatar Feb 14 '20 02:02 williamwei2

I am facing the same issue please help. While working in colab I tried the example

''''''''''''''''''''''' from surprise import SVD from surprise import Dataset from surprise.model_selection import cross_validate

data = Dataset.load_builtin('ml-100k')

algo = SVD()

cross_validate(algo, data, measures=['RMSE', 'MAE'], cv=5, verbose=True) '''''''''''''''''''''''

it gave error

''''''''''''''''''' EOFError Traceback (most recent call last) in () 1 from surprise import Dataset 2 ----> 3 Dataset.load_builtin('ml-100k')

/usr/local/lib/python3.6/dist-packages/surprise/dataset.py in load_builtin(cls, name, prompt) 87 print('Dataset ' + name + ' could not be found. Do you want ' 88 'to download it? [Y/n] ', end='') ---> 89 choice = input().lower() 90 91 if choice in ['yes', 'y', '', 'omg this is so nice of you!!']:

EOFError: EOF when reading a line '''''''''''''''''''

So, in short, I cannot work anywhere on surprise

Om-patel2398 avatar Feb 19 '20 11:02 Om-patel2398

I fixed the above error by changing input() to input('')

Om-patel2398 avatar Feb 19 '20 12:02 Om-patel2398