Python Speedtest 面临认证问题_ssl.c:1056

Rap*_*Gil 1 python speed-test

我正在尝试在 Speedtest API 上使用以下代码

    def get_bytes(self):
        s = speedtest.Speedtest()
        s.get_best_server()
        s.download()
        s.upload()
        res = s.results.dict()
        print(res["download"], res["upload"], res["ping"])
Run Code Online (Sandbox Code Playgroud)

但是,我在这种连接方面遇到了一些问题。我每次都收到此错误。

speedtest.ConfigRetrievalError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)>
Run Code Online (Sandbox Code Playgroud)

我在 MacOS Mojave 上使用 Python 3.7 并且已经尝试在 virtualenv 上更新证书

你有什么主意吗?

Rap*_*Gil 5

伙计们,我终于找到了错误。在这种情况下,您需要在您的机器上安装认证。

认证是:MacintoshHD > Applications > Python 3.7 > Install Certificates.command

双击认证,它会运行这个解决方案。