Python项目部署问题备忘

文章描述了在安装gunicorn库和调用OpenAIAPI时遇到的网络错误,主要表现为因代理问题导致的连接重置。提出的解决方案包括清空http和https的环境变量以避免使用代理,以及检查clash代理日志,切换或修改代理规则以解决连接问题。
摘要由CSDN通过智能技术生成

1.问题:安装依赖库时报网络错误

(base) [root@VM-4-12-centos clash]# pip install gunicorn

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/gunicorn/

WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/gunicorn/

解决方案:尝试修改环境变量

export http_proxy=''

export https_proxy=''

2.请求openapi接口一直报错:

^XRetrying langchain.chat_models.openai.ChatOpenAI.completion_with_retry.<locals>._completion_with_retry in 16.0 seconds as it raised APIConnectionError: Error communicating with OpenAI: HTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/chat/completions (Caused by ProxyError('Cannot connect to proxy.', ConnectionResetError(104, 'Connection reset by peer'))).

解决方案:有可能是clash代理出问题,通过clash日志判断,如果出现:

WARN[0067] [TCP] dial ⚓️其他流量 (match Match/) 127.0.0.1:60624 --> api.openai.com:443 error: dc.xmrthnode.com:42031 connect error: dial tcp4 60.18.196.133:42031: connect: connection refused 

说明是代理问题,这个时候可以尝试切换代理Rule Mode,浏览器中输入:http://yacd.haishan.me/#/proxies

修改代理后重试

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值