Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name 'cosine_similarity' from 'sense2vec.util' #107

Open
Z-e-e opened this issue Apr 23, 2020 · 11 comments
Open
Labels
bug Bugs and behaviour differing from documentation install Installation issues

Comments

@Z-e-e
Copy link

Z-e-e commented Apr 23, 2020

@svlandeg I installed sense2vec through pip I have v 1.0.2 and I get this error:
ImportError: cannot import name 'cosine_similarity' from 'sense2vec.util' (/.conda/envs/NewEnv15/lib/python3.7/site-packages/sense2vec/util.py)

Please let me know what I am doing wrong.

@svlandeg svlandeg added the install Installation issues label Apr 23, 2020
@svlandeg
Copy link
Member

What exactly are you doing when you get that error? Can you post the original command and the entire stacktrace?

@Z-e-e
Copy link
Author

Z-e-e commented Apr 24, 2020

@svlandeg

05_export step:

from collections import OrderedDict, defaultdict
from sense2vec import Sense2Vec
from sense2vec.util import split_key
from sense2vec.util import cosine_similarity
from pathlib import Path
import plac
from wasabi import msg
import numpy

Error:

ImportError Traceback (most recent call last)
in
2 from sense2vec import Sense2Vec
3 from sense2vec.util import split_key
----> 4 from sense2vec.util import cosine_similarity
5 from pathlib import Path
6 import plac

ImportError: cannot import name 'cosine_similarity' from 'sense2vec.util' (/.conda/envs/NewEnv15/lib/python3.7/site-packages/sense2vec/util.py)

@svlandeg
Copy link
Member

I'm a little puzzled by that, because you can import other functions from the same package sense2vec.util (the line above imports split_key), and I just ran the scripts today and didn't run into any trouble ...

@Z-e-e
Copy link
Author

Z-e-e commented Apr 24, 2020

@svlandeg I am quite puzzled myself. Like I mentioned earlier, I used pip to install v 1.0.2. I would like to add that I used Jupyter Hub to run this script. Not sure if that is relevant.

@SarangShaikh201
Copy link

Does any one resolved this issue?

I am facing this same issue as above

@SarangShaikh201
Copy link

Any update on this error?

@hakangs
Copy link

hakangs commented May 12, 2020

@SarangShaikh201 you probably installed sense2vec via pip, can you try to build & install from master branch?

@santoshbs
Copy link

I had the same issue (#110 ). The fix was using the git version of sense2vec rather than the pip version of the package.

@svlandeg
Copy link
Member

svlandeg commented Jun 4, 2020

Thanks for posting the work around @hakangs and @santoshbs! That also explains why I didn't run into trouble because I built from source.

Still need to investigate what goes wrong when installing with pip though.

@svlandeg svlandeg added the bug Bugs and behaviour differing from documentation label Jun 4, 2020
@i-Hun
Copy link

i-Hun commented Jun 25, 2020

Same problem here

@maxpbn
Copy link

maxpbn commented Feb 2, 2021

Same problem here.
Trying to run 05_export.py I face the message: "ImportError: cannot import name 'cosine_similarity' from 'sense2vec.util'"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs and behaviour differing from documentation install Installation issues
Projects
None yet
Development

No branches or pull requests

7 participants