SSL:CERTIFICATE_VERIFY_FAILED] 证书验证失败:无法获取本地颁发者证书 (_ssl.c:11

SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108) Discord/python(SSL:CERTIFICATE_VERIFY_FAILED] 证书验证失败:无法获取本地颁发者证书 (_ssl.c:1108) Discord/python) - IT屋-程序员软
本文介绍了SSL:CERTIFICATE_VERIFY_FAILED] 证书验证失败:无法获取本地颁发者证书 (_ssl.c:1108) Discord/python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在使用 Pycharm 和 python 3.8 以及最新版本的不和谐.我试图运行这个脚本,但得到了这个错误.任何人都可以帮忙吗?

I'm using Pycharm and python 3.8 and latest version of discord. I tried to run this script but got this error. Can anyone help?

import discord

TOKEN = 'xxxxx'

client = discord.Client()

@client.event
async def on_message(message):
    # we do not want the bot to reply to itself
    if message.author == client.user:
        return

    if message.content.startswith('!hello'):
        msg = 'Hello {0.author.mention}'.format(message)
        await client.send_message(message.channel, msg)

@client.event
async def on_ready():
    print('Logged in as')
    print(client.user.name)
    print(client.user.id)
    print('------')

client.run(TOKEN)

----- 下面错误-------

------ error below -------

/Users/mellie/PycharmProjects/Dominations/venv/bin/python/Users/mellie/PycharmProjects/Dominations/Domi.py Traceback(大多数最近通话最后):文件/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/aiohttp/connector.py",第 936 行,在 _wrap_create_connectionreturn await self._loop.create_connection(*args, **kwargs) # type: ignore # noqa File"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py",第 1042 行,在 create_connection 中传输,协议=等待self._create_connection_transport(文件"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py",第 1072 行,在 _create_connection_transport 中等待服务员文件/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/sslproto.py",第 529 行,在 data_received 中ssldata,appdata = self._sslpipe.feed_ssldata(数据)文件/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/sslproto.py",第 189 行,在 feed_ssldata 中self._sslobj.do_handshake() 文件/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py",第 944 行,在 do_handshake 中self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败:无法获取本地颁发者证书 (_ssl.c:1108)

/Users/mellie/PycharmProjects/Dominations/venv/bin/python /Users/mellie/PycharmProjects/Dominations/Domi.py Traceback (most recent call last): File "/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 936, in _wrap_create_connection return await self._loop.create_connection(*args, **kwargs) # type: ignore # noqa File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 1042, in create_connection transport, protocol = await self._create_connection_transport( File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 1072, in _create_connection_transport await waiter File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/sslproto.py", line 529, in data_received ssldata, appdata = self._sslpipe.feed_ssldata(data) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/sslproto.py", line 189, in feed_ssldata self._sslobj.do_handshake() File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 944, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)

上述异常是以下异常的直接原因:

The above exception was the direct cause of the following exception:

Traceback(最近一次调用最后一次):文件/Users/mellie/PycharmProjects/Dominations/Domi.py",第 24 行,在client.run(TOKEN) 文件/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/discord/client.py",第 640 行,运行中返回 future.result() 文件/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/discord/client.py",第 621 行,在亚军中等待 self.start(*args, **kwargs) 文件/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/discord/client.py",第 584 行,开始等待 self.login(*args, bot=bot) 文件/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/discord/client.py",第 442 行,登录等待self.http.static_login(token.strip(),bot = bot)文件/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/discord/http.py",第 256 行,在 static_login 中数据 = 等待 self.request(Route('GET', '/users/@me')) 文件/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/discord/http.py",第 160 行,应要求提供async with self.session.request(method, url, **kwargs) as r: File/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/aiohttp/client.py",第 1012 行,在 __aenterself._resp = 等待 self._coro 文件/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/aiohttp/client.py",第 480 行,在 _request 中conn =等待self._connector.connect(文件/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/aiohttp/connector.py",第 523 行,连接中proto = await self._create_connection(req, traces, timeout) 文件/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/aiohttp/connector.py",第 858 行,在 _create_connection 中_,原型 = 等待 self._create_direct_connection(文件/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/aiohttp/connector.py",第 1004 行,在 _create_direct_connection提出 last_exc 文件/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/aiohttp/connector.py",第 980 行,在 _create_direct_connection 中传输,原型 = 等待 self._wrap_create_connection(文件/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/aiohttp/connector.py",第 938 行,在 _wrap_create_connection引发 ClientConnectorCertificateError(aiohttp.client_exceptions.ClientConnectorCertificateError:不能连接到主机 discordapp.com:443 ssl:True [SSLCertVerificationError:(1, '[SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败:无法获取本地颁发者证书 (_ssl.c:1108)')]

Traceback (most recent call last): File "/Users/mellie/PycharmProjects/Dominations/Domi.py", line 24, in client.run(TOKEN) File "/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/discord/client.py", line 640, in run return future.result() File "/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/discord/client.py", line 621, in runner await self.start(*args, **kwargs) File "/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/discord/client.py", line 584, in start await self.login(*args, bot=bot) File "/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/discord/client.py", line 442, in login await self.http.static_login(token.strip(), bot=bot) File "/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/discord/http.py", line 256, in static_login data = await self.request(Route('GET', '/users/@me')) File "/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/discord/http.py", line 160, in request async with self.session.request(method, url, **kwargs) as r: File "/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/aiohttp/client.py", line 1012, in __aenter self._resp = await self._coro File "/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/aiohttp/client.py", line 480, in _request conn = await self._connector.connect( File "/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 523, in connect proto = await self._create_connection(req, traces, timeout) File "/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 858, in _create_connection _, proto = await self._create_direct_connection( File "/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 1004, in _create_direct_connection raise last_exc File "/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 980, in _create_direct_connection transp, proto = await self._wrap_create_connection( File "/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 938, in _wrap_create_connection raise ClientConnectorCertificateError( aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discordapp.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')]

进程以退出代码 1 结束

Process finished with exit code 1

推荐答案

这个github问题这里.说:

This github issue here. Says:

基本上导航到您的 Applications/Python 3.6/文件夹并加倍单击 Install Certificates.command.

Basically navigate to your Applications/Python 3.6/ folder and double click the Install Certificates.command.

尝试在 3.6 上运行相同的程序并运行安装证书命令.这可能会解决您的问题

Try running this same program on 3.6 and run the install certificates command. This is likely to solve your issue

这篇关于SSL:CERTIFICATE_VERIFY_FAILED] 证书验证失败:无法获取本地颁发者证书 (_ssl.c:1108) Discord/python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How do I make a list of all members in a discord server using discord.py?(如何使用 discord.py 列出不和谐服务器中的所有成员?)
how to change discord.py bot activity(如何更改 discord.py 机器人活动)
Issues with getting VoiceChannel.members and Guild.members to return a full list(让 VoiceChannel.members 和 Guild.members 返回完整列表的问题)
Add button components to a message (discord.py)(将按钮组件添加到消息(discord.py))
on_message() and @bot.command issue(on_message() 和@bot.command 问题)
How to edit a message in discord.py(如何在 discord.py 中编辑消息)