UKPLab / sentence-transformers

State-of-the-Art Text Embeddings
https://www.sbert.net
Apache License 2.0
15.42k stars 2.5k forks source link

installed sentences_transformer successfully but unable to import #1102

Open lukemao opened 3 years ago

lukemao commented 3 years ago

Hi,

I have successfully install sentence_transformers, but I am unable to install:

Requirement already satisfied: six in c:\users\user\appdata\roaming\python\python37\site-packages (from sacremoses->transformers<5.0.0,>=4.6.0->sentence_transformers) (1.15.0)
Collecting threadpoolctl>=2.0.0
  Using cached threadpoolctl-2.2.0-py3-none-any.whl (12 kB)
Collecting pillow>=5.3.0
  Using cached Pillow-8.3.1-1-cp37-cp37m-win_amd64.whl (3.2 MB)
Installing collected packages: tqdm, regex, joblib, filelock, torch, tokenizers, threadpoolctl, sacremoses, pyyaml, pillow, huggingface-hub, transformers, torchvision, sentencepiece, scikit-learn, nltk, sentence-transformers
Successfully installed filelock-3.0.12 huggingface-hub-0.0.12 joblib-1.0.1 nltk-3.6.2 pillow-8.3.1 pyyaml-5.4.1 regex-2021.8.3 sacremoses-0.0.45 scikit-learn-0.24.2 sentence-transformers-2.0.0 sentencepiece-0.1.96 threadpoolctl-2.2.0 tokenizers-0.10.3 torch-1.9.0 torchvision-0.10.0 tqdm-4.62.0 transformers-4.9.2

(faiss) C:\Users\User>python
Python 3.7.11 (default, Jul 27 2021, 09:42:29) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from sentence_transformers import SentenceTransformer
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'sentence_transformers'
>>> from sentence_transformers import SentenceTransformer
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'sentence_transformers'

many thanks

Lu

lukemao commented 3 years ago

installed on anaconda 3.7

nreimers commented 3 years ago

Do you have a file in your folder that is called sentence_transformers.py ?

Also, you are in the faiss environment on anaconda. Are you sure you installed it in that env?

lukemao commented 3 years ago

I deleted 3.7 environment and created 3.6.13 environment. ImportError gone. Strange.

(faiss) E:\shared\workspace\flaskapp\compl>python
Python 3.6.13 |Anaconda, Inc.| (default, Mar 16 2021, 11:37:27) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from sentence_transformers import SentenceTransformer
>>>
lukemao commented 3 years ago

I installed using the command:

(faiss) C:\Users\User>pip install sentence_transformers
... ...
... ...

Installing collected packages: zipp, typing-extensions, urllib3, pyparsing, importlib-metadata, idna, colorama, charset-normalizer, tqdm, six, requests, regex, packaging, numpy, joblib, filelock, dataclasses, click, torch, tokenizers, threadpoolctl, scipy, sacremoses, pyyaml, pillow, huggingface-hub, transformers, torchvision, sentencepiece, scikit-learn, nltk, sentence-transformers
Successfully installed charset-normalizer-2.0.4 click-8.0.1 colorama-0.4.4 dataclasses-0.8 filelock-3.0.12 huggingface-hub-0.0.12 idna-3.2 importlib-metadata-4.6.3 joblib-1.0.1 nltk-3.6.2 numpy-1.19.5 packaging-21.0 pillow-8.3.1 pyparsing-2.4.7 pyyaml-5.4.1 regex-2021.8.3 requests-2.26.0 sacremoses-0.0.45 scikit-learn-0.24.2 scipy-1.5.4 sentence-transformers-2.0.0 sentencepiece-0.1.96 six-1.16.0 threadpoolctl-2.2.0 tokenizers-0.10.3 torch-1.9.0 torchvision-0.10.0 tqdm-4.62.0 transformers-4.9.2 typing-extensions-3.10.0.0 urllib3-1.26.6 zipp-3.5.0

(faiss) C:\Users\User>python
jacobceles commented 2 years ago

I faced a similar issue and installing it on a larger cluster seemed to work.