解决cannot import name ‘DEFAULT_CIPHERS’ from ‘urllib3.util.ssl_’
一、问题
- 运行代码报错如下
{FileNotFoundError}[WinEFailed to import transformers.integrations.peft because of the following error (look up to see its traceback):
cannot import name 'DEFAULT_CIPHERS' from 'urllib3.util.ssl_' (/home/ma-user/anaconda3/envs/PyTorch-2.0.0/lib/python3.9/site-packages/urllib3/util/ssl_.py)rror 2] 系统找不到指定的文件
二、代码
- 经定位发现如下代码抛出异常。
model = AutoModelForCausalLM.from_pretrained(model_path, torch_dtype=now_torch_type,trust_remote_code=True).to("cuda").eval()
三、原因及解决方法
-
原因:urllib3版本兼容性问题。
-
解决方法:
pip uninstall urllib3 pip install urllib3