1、装置杜撰环境conda create --name OPENAI python ==3.7國產av 肛交
看重,一定要python的版块 一定要 3.9及以下!!不然一直会出错出错
图片
图片
ImportError: cannot import name 'COMMON_SAFE_ASCII_CHARACTERS’ from 'charset_normalizer.constant’ (D:\anaconda3\envs\AIGC\lib\site-packages\charset_normalizer\constant.py)用
pip install chardet pip install charset-normalizer==2.1.0
皆不论用
文轩 探花要确保python的版块号最佳python>=3.8 不然openai的有些库不成用
conda install python==3.8
2、装置openai又是出错
ERROR: Could not find a version that satisfies the requirement openai (from versions: none) ERROR: No matching distribution found for openai
这本领用国内源就好了
pip install openai -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
3、衔尾不上一直出现问题
openai.error.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.', OSError(0, 'Error')))
自后在知乎回应—— 找到了谜底原因是
urllib3的版块问题,环境内的urllib3版块是1.26.14版块,回退到1.25.11版块问题就处理了。
搜检了一下urllib3的更新日记,应该是1.26.0的修改导致的:
临了
conda install urllib3==1.25.11
4、一直清楚无chatCompletion即清楚
AttributeError: module 'openai' has no attribute 'ChatCompletion'
openai的版块号不够新,参照2进行更新
pip install -U openai -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
能跑通啦,棒棒!!!!
5、no model named win32api
pip install win32api ERROR: Could not find a version that satisfies the requirement win32api (from versions: none) ERROR: No matching distribution found for win32api
骨子的装置身手
conda install win32api
6、衔尾失实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.’, NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x0000027039BA40A0>: Failed to establish a new connection: [WinError 10061] 由于策画洽商机积极终止,无法衔尾。’)))
处理身手处理主义:
①掀开文献旅途:D:\Anaconda3\envs\py\Lib\site-packages\openai\api_reuqestor.py(openai库旅途)
②找到if not hasattr(_thread_context,“session”): 身手,并在此身手上加入代理。(此身手大约在512行)每一个东说念主的代理不一定相通
图片
图片
# proxy = { # 'http': 'http://<代理ip>:<代理端口>', # 'https': 'https://<代理ip>:<代理端口>' # } proxy={ 'http':'127.0.0.1:10809', 'https':'127.0.0.1:10809' }
③在result = _thread_context.session.request(中加入代理
result = _thread_context.session.request( method, abs_url, headers=headers, data=data, files=files, stream=stream, timeout=request_timeout if request_timeout else TIMEOUT_SECS, proxies=proxy # 新增此行 )
result = _thread_context.session.request( method, abs_url, headers=headers, data=data, files=files, stream=stream, timeout=request_timeout if request_timeout else TIMEOUT_SECS, proxies=proxy # 新增此行 )
再次伊始API测试代码发现还是告捷复返数据
版权声明:本文为博主原创著作,奉命 CC 4.0 BY-SA 版权条约,转载请附上原文出处衔尾和本声明vb.net教程C#教程python教程。
原文衔尾:https://blog.csdn.net/weixin_43818488/article/details/129811845國產av 肛交
本站仅提供存储劳动,所有这个词内容均由用户发布,如发现存害或侵权内容,请点击举报。