tlqn
tlqn

Reputation: 399

Cannot import name "is_sklearn_available" from "transformers.data"

I installed the package sentence_transformers via conda. It was successful; however, I cannot load them in jupyter notebook. I kept receiving the error as below. I have already upgraded all the relevant packages (sklearn, scipy, etc.) and I still receive the error.

from sentence_transformers import SentenceTransformer

ImportError: cannot import name 'is_sklearn_available' from 'transformers.data' (/Users/KK/opt/anaconda3/lib/python3.7/site-packages/transformers/data/__init__.py)

Any suggestions would be greatly appreciated.

Upvotes: 2

Views: 2408

Answers (2)

Arju Mann
Arju Mann

Reputation: 1

I faced this error as well. My mistake was that I was trying to import is_sklearn_available from transformers/data/init.py when I should have been importing it from transformers/file_utils.py Please check your init.py files for a better picture.

Upvotes: 0

Ohtar10
Ohtar10

Reputation: 128

I have faced this issue too. In my case, after restarting the jupyter kernel it worked without problems.

In my case, first I installed transformers 3.4.0, but had to downgrade to 3.1.0 due to a TF 2.1 compatibility issue. I downgraded without restarting the kernel and I got the same error message. After kernel restart, everything worked fine.

Upvotes: 1

Related Questions