2

I'm trying to use huggingface transformers. (Win 11, Python 3.9, jupyternotebook, virtual environment)

When I ran code:

from transformers import pipeline
print(pipeline('sentiment-analysis')('I hate you'))

I got an error :

FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\Users\user/.cache\huggingface'

There's no directory named '.cache' in my user folder, so I used cache_dir="./cache" but I want to change the path of the directory permanently.

P.S.

import os
os.environ['TRANSFORMERS_CACHE'] = './cache'

also didn't work.

cronoik
  • 15,434
  • 3
  • 40
  • 78
PCho
  • 21
  • 1
  • 3
  • 1
    I am not using Windows, but can you set `os.environ['TRANSFORMERS_CACHE'] = './cache'` to an actual windows path and tell me what happens? Keep in mind that you need to set this environment variable before you import transformers! – cronoik Sep 05 '22 at 11:25
  • 1
    "you need to set this environment variable before you import transformers" << This was the key to solving this problem. Thank you – PCho Sep 11 '22 at 09:03

0 Answers0