Rit*_*ore 4 windows proxy machine-learning deep-learning huggingface-transformers
我正在尝试在代理后面使用拥抱面部管道。考虑以下代码行
from transformers import pipeline
sentimentAnalysis_pipeline = pipeline("sentiment-analysis")
Run Code Online (Sandbox Code Playgroud)
上面的代码给出了以下错误。
HTTPSConnectionPool(host='huggingface.co', port=443): url 超出最大重试次数:/distilbert-base-uncased-finetuned-sst-2-english/resolve/main/config.json (由 ProxyError('Your代理似乎只使用 HTTP 而不是 HTTPS,请尝试将代理 URL 更改为 HTTP。请参阅:https: //urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#https-proxy-error-http -proxy' , SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] 版本号错误 (_ssl.c:1091)'))))
我尝试使用以下代码检查具有操作系统“windows server 2016 Datacenter”的计算机上的代理。
import urllib.request
print(urllib.request.getproxies())
Run Code Online (Sandbox Code Playgroud)
输出如下:
{'http': 'http://12.10.10.12:8080', 'https': 'https://12.10.10.12:8080', 'ftp': 'ftp://12.10.10.12:8080'}
Run Code Online (Sandbox Code Playgroud)
但是,根据urlib3页面的文档,上述设置不兼容,问题在于 https 设置:
{
"http": "http://127.0.0.1:8888",
"https": "https://127.0.0.1:8888" # <--- This setting is the problem!
}
Run Code Online (Sandbox Code Playgroud)
正确的设置是
{ # Everything is good here! :)
"http": "http://127.0.0.1:8888",
"https": "http://127.0.0.1:8888"
}
Run Code Online (Sandbox Code Playgroud)
我们如何在 Windows 操作系统中将"https": "https://127.0.0.1:8888"代理设置更改为 ?"https": "http://127.0.0.1:8888"
我尝试将 Windows 环境变量名称设置为"https_proxy"并将变量值设置为http://127.0.0.1:8888。但是,它不起作用。
我找到了解决方案,而且非常简单。在您的 python 脚本/笔记本中包含以下行。根据您的设置更改 proxy_url 和端口。我希望它对社区中的某个人有所帮助。
import os
os.environ['HTTP_PROXY'] = 'http://proxy_url:proxy_port'
os.environ['HTTPS_PROXY'] = 'http://proxy_url:proxy_port'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6315 次 |
| 最近记录: |