我使用的是情感分析管道,如描述的这里。
from transformers import pipeline
classifier = pipeline('sentiment-analysis')它的连接错误消息失败了
ValueError:连接错误,我们无法在缓存的路径中找到请求的文件。请再试一次,或确保您的互联网连接已开启。
是否有方法在管道方法中指定代理,以便它能够连接到internet并下载所需的文件?
发布于 2022-04-25 07:47:49
应该是代理问题。您可以尝试添加此代码片段以遍历代理。
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')注意:记住对代理值使用http而不是https。
https://stackoverflow.com/questions/65247333
复制相似问题