explosion/sense2vec

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

Z-e-e opened this issue · 11 comments

Z-e-e commented

@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.

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

Z-e-e commented

@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)

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 commented

@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.

Does any one resolved this issue?

I am facing this same issue as above

Any update on this error?

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

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

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.

i-Hun commented

Same problem here

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