gpt4 book ai didi

python - youtube-dl 的证书验证失败

转载 作者:太空宇宙 更新时间:2023-11-04 00:24:06 25 4
gpt4 key购买 nike

我正在尝试使用以下命令从 YouTube 视频中获取音频:

youtube-dl --extract-audio --audio-format mp3 [video link]

每次我尝试在 macOS (High Sierra v10.13.2) 的终端中运行这个命令时,它都会给我这个错误:

ERROR: Unable to download webpage: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)> (caused by URLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)'),))

注意:我安装了 youtube-dl,还有 Python 2.7 和 Python 3.6(如果有帮助的话)

如果有人能帮我解决这个问题,那就太好了。

最佳答案

这个问题我已经有一段时间了,一直没能解决。所以我临时修复了

[终端]

--no-check-certificate

遗憾的是,这只会将您的 HTTPS youtube-dl 请求变成纯文本 HTTP 请求。

经过一番挖掘,我发现这是一个 Python v3.6 问题。

https://bugs.python.org/issue29065#msg283984

如果你使用VIM或者任何编辑来检查

vim '/Applications/Python 3.6/ReadMe.rtf'

如果您寻找(证书验证和 OpenSSL\)你会看到......

在安装 Python v3.6 期间,他们决定使用他们自己的私有(private)版本的 OpenSSL,不幸的是,它本身不能与默认的根证书一起使用。但是,它确实带有一个命令脚本来安装精选的默认根证书包。

bug 推荐我使用 python certifi模块。这些模块似乎非常适合查找您的证书所在的位置。

[Python v3.6]

import certifi

certifi.where()

'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/certifi/cacert.pem'

这实际上只是告诉了它在哪里,但为了以防万一,我使用了 python 终端解释器。

[终端]

open '/Applications/Python 3.6/Install Certificates.command'

就我个人而言,这是我的终端响应...

[终端]

-- pip install --upgrade certifi

Requirement already up-to-date: certifi in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages

-- removing any existing file or link

-- creating symlink to certifi certificate bundle

-- setting permissions

Traceback (most recent call last):

File "", line 44, in

File "", line 40, in main

PermissionError: [Errno 1] Operation not permitted: 'cert.pem'

logout

Saving session...

...copying shared history...

...saving history...truncating history files...

...completed.

[Process completed]

但它起作用了,我不必再处理 S​​SL 验证失败了! (-.-)\/(-.-)/

关于python - youtube-dl 的证书验证失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48064876/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com