已复制
全屏展示
复制代码

Python错误 certificate verify failed: unable to get local issuer certificate 解决

· 1 min read

在安装语音识别包 whisper 的时候,遇到如下错误。


whisper -f srt ../edge-tts-test/xxxby_edge_tts.mp3 --language Japanese
During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/yzy/tmpy/whisper_test/venv/bin/whisper", line 8, in <module>
    sys.exit(cli())
  File "/Users/yzy/tmpy/whisper_test/venv/lib/python3.9/site-packages/whisper/transcribe.py", line 444, in cli
    model = load_model(model_name, device=device, download_root=model_dir)
  File "/Users/yzy/tmpy/whisper_test/venv/lib/python3.9/site-packages/whisper/__init__.py", line 131, in load_model
    checkpoint_file = _download(_MODELS[name], download_root, in_memory)
  File "/Users/yzy/tmpy/whisper_test/venv/lib/python3.9/site-packages/whisper/__init__.py", line 67, in _download
    with urllib.request.urlopen(url) as source, open(download_target, "wb") as output:
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 517, in open
    response = self._open(req, data)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 534, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 1389, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 1349, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)>

解决办法:首先找到运行的脚本文件位置 which whisper,然后编辑脚本,添加如下代码在脚本中即可。


import ssl

ssl._create_default_https_context = ssl._create_unverified_context
🔗

文章推荐