'How to specify a proxy in transformers pipeline
I am using sentiment-analysis pipeline as described here.
from transformers import pipeline
classifier = pipeline('sentiment-analysis')
It's failing with a connection error message
ValueError: Connection error, and we cannot find the requested files in the cached path. Please try again or make sure your Internet connection is on.
Is there a way to specify a proxy within the pipeline method so that it's able to connect to the internet and download the files needed?
Solution 1:[1]
It should be proxy problem. You can try add this code snippet to go through proxies.
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')
Note: Remember to use http instead of https for the proxy value.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Quan Nguyen |