Sentence-transformers: Could not find a version that satisfies the requirement torch>=1.0.1 (from sentence-transformers) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)

Created on 12 Jan 2020  路  15Comments  路  Source: UKPLab/sentence-transformers

Using Python 3.8.1
Windows 10 OS

Not sure what I need to do to fix this..

Most helpful comment

I tried to Conda Install pytorch and then installed Sentence Transformer by doing these steps:

conda install pytorch torchvision cudatoolkit=10.0 -c pytorch

pip install -U sentence-transformers

This worked on Windows.

All 15 comments

Pytorch has no binaries yet for Python 3.8
https://github.com/pytorch/pytorch/issues/29090

Easiest way would be to use Python 3.6 or Python 3.7

I uninstalled python 3.8 and installed 3.7 but I am still getting the same error message.

PS C:WINDOWSsystem32> pip install -U sentence-transformers
Collecting sentence-transformers
Using cached https://files.pythonhosted.org/packages/c9/91/c85ddef872d5bb39949386930c1f834ac382e145fcd30155b09d6fb65c5a/sentence-transformers-0.2.5.tar.gz
Requirement already satisfied, skipping upgrade: transformers==2.3.0 in c:program files (x86)python37-32libsite-packages (from sentence-transformers) (2.3.0)
Requirement already satisfied, skipping upgrade: tqdm in c:program files (x86)python37-32libsite-packages (from sentence-transformers) (4.41.1)
Collecting torch>=1.0.1 (from sentence-transformers)
ERROR: Could not find a version that satisfies the requirement torch>=1.0.1 (from sentence-transformers) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)
ERROR: No matching distribution found for torch>=1.0.1 (from sentence-transformers)

Can you try to install pytorch as described here
https://pytorch.org/get-started/locally/

I am getting the same message when I try to install pytorch through that link.

ERROR: Could not find a version that satisfies the requirement torch==1.3.1+cpu (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)
ERROR: No matching distribution found for torch==1.3.1+cpu

I was able to install pytorch using conda, what should I do now?

Thank you for all your time and help so far.

Clone the repository and try to install it with:
pip install -e .

Maybe you need to remove the torch requirement from the setup-file.

Same message. I tried installing the previous 1.0.1 version of torch since the current version is 1.3 and it didn't change anything either.

Should I try switching my OS to Linux and use Ubuntu?

I opened the setup.py file and deleted the torch requirement and it worked or so it seems. I used this example from your repository:

from sentence_transformers import SentenceTransformer
from sklearn.cluster import KMeans

embedder = SentenceTransformer('bert-base-nli-mean-tokens')

corpus = ['A man is eating food.',
'A man is eating a piece of bread.',
'A man is eating pasta.',
'The girl is carrying a baby.',
'The baby is carried by the woman',
'A man is riding a horse.',
'A man is riding a white horse on an enclosed ground.',
'A monkey is playing drums.',
'Someone in a gorilla costume is playing a set of drums.',
'A cheetah is running behind its prey.',
'A cheetah chases prey on across a field.'
]
corpus_embeddings = embedder.encode(corpus)

num_clusters = 5
clustering_model = KMeans(n_clusters=num_clusters)
clustering_model.fit(corpus_embeddings)
cluster_assignment = clustering_model.labels_

clustered_sentences = [[] for i in range(num_clusters)]
for sentence_id, cluster_id in enumerate(cluster_assignment):
clustered_sentences[cluster_id].append(corpus[sentence_id])

for i, cluster in enumerate(clustered_sentences):
print("Cluster ", i+1)
print(cluster)
print("")

But I get this message:

Traceback (most recent call last):
File "C:UsersBrettDocumentstest.py", line 1, in
from sentence_transformers import SentenceTransformer
File "c:usersbrettdownloadssentence-transformerssentence_transformers__init__.py", line 3, in
from .datasets import SentencesDataset, SentenceLabelDataset
File "c:usersbrettdownloadssentence-transformerssentence_transformersdatasets.py", line 5, in
from torch.utils.data import Dataset
ModuleNotFoundError: No module named 'torch'

Torch appears not to be install or cannot be loaded.

Windows + Python + Deep Learning is a rather suboptimal combination and many module will not work correctly. For Windows, I made good experiences with Anaconda:
https://www.anaconda.com/distribution/

But in general, if you want to work with deep learning frameworks, it is better to use a linux based operating system. This causes a lot less issues with many different libraries.

Switched to linux and got everything working. Now I can't believe I've been using Windows my whole life. Thank you for all your help along the way!

I tried to Conda Install pytorch and then installed Sentence Transformer by doing these steps:

conda install pytorch torchvision cudatoolkit=10.0 -c pytorch

pip install -U sentence-transformers

This worked on Windows.

conda install pytorch torchvision cudatoolkit=10.0 -c pytorch

I have tired your method but it still didn't work:

ERROR: Could not find a version that satisfies the requirement torch>=1.0.1 (from sentence-transformers) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)
ERROR: No matching distribution found for torch>=1.0.1 (from sentence-transformers)

I tried to Conda Install pytorch and then installed Sentence Transformer by doing these steps:

conda install pytorch torchvision cudatoolkit=10.0 -c pytorch

pip install -U sentence-transformers

This worked on Windows.

It worked for me on Windows 10 and PyCharm 2020.1.

Worked for me too

I tried to Conda Install pytorch and then installed Sentence Transformer by doing these steps:

conda install pytorch torchvision cudatoolkit=10.0 -c pytorch

pip install -U sentence-transformers

This worked on Windows.

Worked for me too! Thank you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

anatoly-khomenko picture anatoly-khomenko  路  5Comments

earny-joe picture earny-joe  路  3Comments

shivprasad94 picture shivprasad94  路  3Comments

zishanmuzeeb picture zishanmuzeeb  路  4Comments

RuskinManku picture RuskinManku  路  5Comments