Kum*_*mar 7 python bert-language-model huggingface-transformers
我正在使用此处描述的情感分析管道。
from transformers import pipeline
classifier = pipeline('sentiment-analysis')
Run Code Online (Sandbox Code Playgroud)
失败并显示连接错误消息
ValueError:连接错误,我们在缓存路径中找不到请求的文件。请重试或确保您的互联网连接已打开。
有没有办法在管道方法中指定代理,以便它能够连接到互联网并下载所需的文件?
小智 5
应该是代理问题。您可以尝试添加此代码片段以通过代理。
import os
os.environ['HTTP_PROXY'] = 'http://xxx:xxx@xxx:xxx'
os.environ['HTTPS_PROXY'] = 'http://xxx:xxx@xxx:xxx'
from transformers import pipeline
classifier = pipeline('sentiment-analysis')
Run Code Online (Sandbox Code Playgroud)
注意:请记住使用http而不是https作为代理值。