question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ImportError: universal-sentence-encoder is not available.

See original GitHub issue

Hi! I’m getting the above error on the following code:

from top2vec import Top2Vec
model = Top2Vec(documents=df['transcript'].values, speed="learn", embedding_model='universal-sentence-encoder')

Full Exception Traceback:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-3-12fb6ba4e3a8> in <module>
      1 from top2vec import Top2Vec
      2 
----> 3 model = Top2Vec(documents=df['transcript'].values, speed="learn", embedding_model='universal-sentence-encoder')

~\Anaconda3\lib\site-packages\top2vec\Top2Vec.py in __init__(self, documents, min_count, embedding_model, embedding_model_path, speed, use_corpus_file, document_ids, keep_documents, workers, tokenizer, verbose)
    278             self.embedding_model = embedding_model
    279 
--> 280             self._check_import_status()
    281 
    282             logger.info('Pre-processing documents for training')

~\Anaconda3\lib\site-packages\top2vec\Top2Vec.py in _check_import_status(self)
    642         if self.embedding_model != 'distiluse-base-multilingual-cased':
    643             if not _HAVE_TENSORFLOW:
--> 644                 raise ImportError(f"{self.embedding_model} is not available.\n\n"
    645                                   "Try: pip install top2vec[sentence_encoders]\n\n"
    646                                   "Alternatively try: pip install tensorflow tensorflow_hub tensorflow_text")

ImportError: universal-sentence-encoder is not available.

Try: pip install top2vec[sentence_encoders]

Alternatively try: pip install tensorflow tensorflow_hub tensorflow_text

I have all of these libraries installed (see below) - but this error wont go.

(base) C:\Users\rsiddiqui>pip install top2vec[sentence_encoders] Requirement already satisfied: top2vec[sentence_encoders] in c:\users\rsiddiqui\anaconda3\lib\site-packages (1.0.16) Requirement already satisfied: numpy in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from top2vec[sentence_encoders]) (1.18.5) Requirement already satisfied: umap-learn in c:\users\rsiddiqui\anaconda3\lib\site-packages (from top2vec[sentence_encoders]) (0.4.6) Requirement already satisfied: gensim in c:\users\rsiddiqui\anaconda3\lib\site-packages (from top2vec[sentence_encoders]) (3.8.3) Requirement already satisfied: pandas in c:\users\rsiddiqui\anaconda3\lib\site-packages (from top2vec[sentence_encoders]) (1.1.3) Requirement already satisfied: wordcloud in c:\users\rsiddiqui\anaconda3\lib\site-packages (from top2vec[sentence_encoders]) (1.8.1) Requirement already satisfied: hdbscan in c:\users\rsiddiqui\anaconda3\lib\site-packages (from top2vec[sentence_encoders]) (0.8.26) Requirement already satisfied: pynndescent>=0.4 in c:\users\rsiddiqui\anaconda3\lib\site-packages (from top2vec[sentence_encoders]) (0.5.1) Requirement already satisfied: tensorflow-text; extra == “sentence_encoders” in c:\users\rsiddiqui\anaconda3\lib\site-packages (from top2vec[sentence_encoders]) (2.4.0rc0) Requirement already satisfied: tensorflow-hub; extra == “sentence_encoders” in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from top2vec[sentence_encoders]) (0.9.0) Requirement already satisfied: tensorflow; extra == “sentence_encoders” in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from top2vec[sentence_encoders]) (2.3.1) Requirement already satisfied: numba!=0.47,>=0.46 in c:\users\rsiddiqui\anaconda3\lib\site-packages (from umap-learn->top2vec[sentence_encoders]) (0.51.2) Requirement already satisfied: scikit-learn>=0.20 in c:\users\rsiddiqui\anaconda3\lib\site-packages (from umap-learn->top2vec[sentence_encoders]) (0.23.2) Requirement already satisfied: scipy>=1.3.1 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from umap-learn->top2vec[sentence_encoders]) (1.5.4) Requirement already satisfied: smart-open>=1.8.1 in c:\users\rsiddiqui\anaconda3\lib\site-packages (from gensim->top2vec[sentence_encoders]) (3.0.0) Requirement already satisfied: six>=1.5.0 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from gensim->top2vec[sentence_encoders]) (1.15.0) Requirement already satisfied: Cython==0.29.14 in c:\users\rsiddiqui\anaconda3\lib\site-packages (from gensim->top2vec[sentence_encoders]) (0.29.14) Requirement already satisfied: python-dateutil>=2.7.3 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from pandas->top2vec[sentence_encoders]) (2.8.1) Requirement already satisfied: pytz>=2017.2 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from pandas->top2vec[sentence_encoders]) (2020.4) Requirement already satisfied: pillow in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from wordcloud->top2vec[sentence_encoders]) (8.0.1) Requirement already satisfied: matplotlib in c:\users\rsiddiqui\anaconda3\lib\site-packages (from wordcloud->top2vec[sentence_encoders]) (3.2.2) Requirement already satisfied: joblib in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from hdbscan->top2vec[sentence_encoders]) (0.15.1) Requirement already satisfied: llvmlite>=0.30 in c:\users\rsiddiqui\anaconda3\lib\site-packages (from pynndescent>=0.4->top2vec[sentence_encoders]) (0.34.0) Requirement already satisfied: protobuf>=3.8.0 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow-hub; extra == “sentence_encoders”->top2vec[sentence_encoders]) (3.13.0) Requirement already satisfied: tensorflow-estimator<2.4.0,>=2.3.0 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow; extra == “sentence_encoders”->top2vec[sentence_encoders]) (2.3.0) Requirement already satisfied: google-pasta>=0.1.8 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow; extra == “sentence_encoders”->top2vec[sentence_encoders]) (0.2.0) Requirement already satisfied: wheel>=0.26 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow; extra == “sentence_encoders”->top2vec[sentence_encoders]) (0.35.1) Requirement already satisfied: absl-py>=0.7.0 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow; extra == “sentence_encoders”->top2vec[sentence_encoders]) (0.10.0) Requirement already satisfied: h5py<2.11.0,>=2.10.0 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow; extra == “sentence_encoders”->top2vec[sentence_encoders]) (2.10.0) Requirement already satisfied: termcolor>=1.1.0 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow; extra == “sentence_encoders”->top2vec[sentence_encoders]) (1.1.0) Requirement already satisfied: keras-preprocessing<1.2,>=1.1.1 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow; extra == “sentence_encoders”->top2vec[sentence_encoders]) (1.1.2) Requirement already satisfied: opt-einsum>=2.3.2 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow; extra == “sentence_encoders”->top2vec[sentence_encoders]) (3.3.0) Requirement already satisfied: wrapt>=1.11.1 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow; extra == “sentence_encoders”->top2vec[sentence_encoders]) (1.12.1) Requirement already satisfied: grpcio>=1.8.6 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow; extra == “sentence_encoders”->top2vec[sentence_encoders]) (1.32.0) Requirement already satisfied: gast==0.3.3 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow; extra == “sentence_encoders”->top2vec[sentence_encoders]) (0.3.3) Requirement already satisfied: astunparse==1.6.3 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow; extra == “sentence_encoders”->top2vec[sentence_encoders]) (1.6.3) Requirement already satisfied: tensorboard<3,>=2.3.0 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow; extra == “sentence_encoders”->top2vec[sentence_encoders]) (2.4.0) Requirement already satisfied: setuptools in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from numba!=0.47,>=0.46->umap-learn->top2vec[sentence_encoders]) (50.3.2) Requirement already satisfied: threadpoolctl>=2.0.0 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from scikit-learn>=0.20->umap-learn->top2vec[sentence_encoders]) (2.1.0) Requirement already satisfied: requests in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from smart-open>=1.8.1->gensim->top2vec[sentence_encoders]) (2.25.0) Requirement already satisfied: kiwisolver>=1.0.1 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from matplotlib->wordcloud->top2vec[sentence_encoders]) (1.3.1) Requirement already satisfied: cycler>=0.10 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from matplotlib->wordcloud->top2vec[sentence_encoders]) (0.10.0) Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from matplotlib->wordcloud->top2vec[sentence_encoders]) (2.4.7) Requirement already satisfied: google-auth-oauthlib<0.5,>=0.4.1 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorboard<3,>=2.3.0->tensorflow; extra == “sentence_encoders”->top2vec[sentence_encoders]) (0.4.2) Requirement already satisfied: werkzeug>=0.11.15 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorboard<3,>=2.3.0->tensorflow; extra == “sentence_encoders”->top2vec[sentence_encoders]) (1.0.1) Requirement already satisfied: tensorboard-plugin-wit>=1.6.0 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorboard<3,>=2.3.0->tensorflow; extra == “sentence_encoders”->top2vec[sentence_encoders]) (1.7.0) Requirement already satisfied: markdown>=2.6.8 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorboard<3,>=2.3.0->tensorflow; extra == “sentence_encoders”->top2vec[sentence_encoders]) (3.3.3) Requirement already satisfied: google-auth<2,>=1.6.3 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorboard<3,>=2.3.0->tensorflow; extra == “sentence_encoders”->top2vec[sentence_encoders]) (1.23.0) Requirement already satisfied: idna<3,>=2.5 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from requests->smart-open>=1.8.1->gensim->top2vec[sentence_encoders]) (2.10) Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from requests->smart-open>=1.8.1->gensim->top2vec[sentence_encoders]) (1.26.2) Requirement already satisfied: certifi>=2017.4.17 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from requests->smart-open>=1.8.1->gensim->top2vec[sentence_encoders]) (2020.11.8) Requirement already satisfied: chardet<4,>=3.0.2 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from requests->smart-open>=1.8.1->gensim->top2vec[sentence_encoders]) (3.0.4) Requirement already satisfied: requests-oauthlib>=0.7.0 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard<3,>=2.3.0->tensorflow; extra == “sentence_encoders”->top2vec[sentence_encoders]) (1.3.0) Requirement already satisfied: cachetools<5.0,>=2.0.0 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from google-auth<2,>=1.6.3->tensorboard<3,>=2.3.0->tensorflow; extra == “sentence_encoders”->top2vec[sentence_encoders]) (4.1.1) Requirement already satisfied: pyasn1-modules>=0.2.1 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from google-auth<2,>=1.6.3->tensorboard<3,>=2.3.0->tensorflow; extra == “sentence_encoders”->top2vec[sentence_encoders]) (0.2.8) Requirement already satisfied: rsa<5,>=3.1.4; python_version >= “3.5” in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from google-auth<2,>=1.6.3->tensorboard<3,>=2.3.0->tensorflow; extra == “sentence_encoders”->top2vec[sentence_encoders]) (4.6) Requirement already satisfied: oauthlib>=3.0.0 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard<3,>=2.3.0->tensorflow; extra == “sentence_encoders”->top2vec[sentence_encoders]) (3.1.0) Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from pyasn1-modules>=0.2.1->google-auth<2,>=1.6.3->tensorboard<3,>=2.3.0->tensorflow; extra == “sentence_encoders”->top2vec[sentence_encoders]) (0.4.8)

(base) C:\Users\rsiddiqui>pip install tensorflow tensorflow_hub tensorflow_text Requirement already satisfied: tensorflow in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (2.3.1) Requirement already satisfied: tensorflow_hub in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (0.9.0) Requirement already satisfied: tensorflow_text in c:\users\rsiddiqui\anaconda3\lib\site-packages (2.4.0rc0) Requirement already satisfied: protobuf>=3.9.2 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow) (3.13.0) Requirement already satisfied: gast==0.3.3 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow) (0.3.3) Requirement already satisfied: termcolor>=1.1.0 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow) (1.1.0) Requirement already satisfied: tensorboard<3,>=2.3.0 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow) (2.4.0) Requirement already satisfied: grpcio>=1.8.6 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow) (1.32.0) Requirement already satisfied: tensorflow-estimator<2.4.0,>=2.3.0 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow) (2.3.0) Requirement already satisfied: astunparse==1.6.3 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow) (1.6.3) Requirement already satisfied: six>=1.12.0 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow) (1.15.0) Requirement already satisfied: wrapt>=1.11.1 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow) (1.12.1) Requirement already satisfied: google-pasta>=0.1.8 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow) (0.2.0) Requirement already satisfied: keras-preprocessing<1.2,>=1.1.1 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow) (1.1.2) Requirement already satisfied: wheel>=0.26 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow) (0.35.1) Requirement already satisfied: opt-einsum>=2.3.2 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow) (3.3.0) Requirement already satisfied: h5py<2.11.0,>=2.10.0 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow) (2.10.0) Requirement already satisfied: numpy<1.19.0,>=1.16.0 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow) (1.18.5) Requirement already satisfied: absl-py>=0.7.0 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorflow) (0.10.0) Requirement already satisfied: setuptools in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from protobuf>=3.9.2->tensorflow) (50.3.2) Requirement already satisfied: requests<3,>=2.21.0 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorboard<3,>=2.3.0->tensorflow) (2.25.0) Requirement already satisfied: tensorboard-plugin-wit>=1.6.0 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorboard<3,>=2.3.0->tensorflow) (1.7.0) Requirement already satisfied: werkzeug>=0.11.15 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorboard<3,>=2.3.0->tensorflow) (1.0.1) Requirement already satisfied: google-auth<2,>=1.6.3 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorboard<3,>=2.3.0->tensorflow) (1.23.0) Requirement already satisfied: google-auth-oauthlib<0.5,>=0.4.1 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorboard<3,>=2.3.0->tensorflow) (0.4.2) Requirement already satisfied: markdown>=2.6.8 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from tensorboard<3,>=2.3.0->tensorflow) (3.3.3) Requirement already satisfied: chardet<4,>=3.0.2 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from requests<3,>=2.21.0->tensorboard<3,>=2.3.0->tensorflow) (3.0.4) Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from requests<3,>=2.21.0->tensorboard<3,>=2.3.0->tensorflow) (1.26.2) Requirement already satisfied: idna<3,>=2.5 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from requests<3,>=2.21.0->tensorboard<3,>=2.3.0->tensorflow) (2.10) Requirement already satisfied: certifi>=2017.4.17 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from requests<3,>=2.21.0->tensorboard<3,>=2.3.0->tensorflow) (2020.11.8) Requirement already satisfied: rsa<5,>=3.1.4; python_version >= “3.5” in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from google-auth<2,>=1.6.3->tensorboard<3,>=2.3.0->tensorflow) (4.6) Requirement already satisfied: pyasn1-modules>=0.2.1 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from google-auth<2,>=1.6.3->tensorboard<3,>=2.3.0->tensorflow) (0.2.8) Requirement already satisfied: cachetools<5.0,>=2.0.0 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from google-auth<2,>=1.6.3->tensorboard<3,>=2.3.0->tensorflow) (4.1.1) Requirement already satisfied: requests-oauthlib>=0.7.0 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard<3,>=2.3.0->tensorflow) (1.3.0) Requirement already satisfied: pyasn1>=0.1.3 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from rsa<5,>=3.1.4; python_version >= “3.5”->google-auth<2,>=1.6.3->tensorboard<3,>=2.3.0->tensorflow) (0.4.8) Requirement already satisfied: oauthlib>=3.0.0 in c:\users\rsiddiqui\appdata\roaming\python\python38\site-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard<3,>=2.3.0->tensorflow) (3.1.0)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
ddangelovcommented, Dec 15, 2020

Did you pip install top2vec[sentence_encoders]? If you are on Windows see #44

0reactions
sdspiegcommented, Dec 5, 2022

This still does not work for me (in Google Colab) - “ImportError: universal-sentence-encoder is not available.”. And this despite the fact that I do !pip install top2vec[sentence_encoders] top2vec[sentence_transformers] top2vec[indexing]. I even tried !pip install -U sentence-transformers. Is there really no fool-proof method for making this work?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error creating universal sentence encoder embeddings using ...
I have a simple beam pipline that takes some text and gets embeddings using universal sentence encoder with tf transform.
Read more >
Disaster NLP: Train a Universal Sentence Encoder - Kaggle
Universal Sentence Encoder is a model created and publicly made available by Google. Built in Tensorflow, it was trained to embed any type...
Read more >
How to solve a problem on Kaggle with TF-Hub - TensorFlow
except ImportError: raise ValueError("Could not find kaggle token.")
Read more >
08. Natural Language Processing with TensorFlow
Passing our sentences to the Universal Sentence Encoder (USE) encodes them from strings to 512 dimensional vectors, which make no sense to us...
Read more >
tensorflow-metal | Apple Developer Forums
... To train the model with embedding_model="universal-sentence-encoder", ... Tensorflow is working but Tensorflow addons is not getting installed.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found