2017-11-17 8 views
-6

私は不和のためにチャットボットを書いており、今日まで完全に稼働しています。私は今日それを実行しようとしたとき、私はこのようになります巨大なエラーが発生しました:Python 3.6.2でこの巨大なエラーが発生するのはなぜですか?

enter image description here

誰かが、私はこの大きな前に、私のエラーを得たことがないので、私はここで何が起こっているかを把握助けることができます"[[SSL:CERTIFICATE_VERIFY_FAILED]証明書の検証に失敗しました(_ssl.c:777)]]のようなものを取得しないでください。

私は、discord.py、asyncioモジュールでPython 3.6.2を使用しています。

また、私はこのプログラムをSublimeREPLでSublimeREPLで実行しています。

ご協力いただきまして誠にありがとうございます。

コード:

import discord 
import asyncio 
import random 
import smtplib 

client = discord.Client() 

# When the bot is ready and online. 
@client.event 
async def on_ready(): 
    print("logged in as:", client.user.name) 
    print("ID:", client.user.id) 
    print("Ready to go!") 


# When a message is sent. 
@client.event 
async def on_message(message): 
    if message.author == client.user: 
     return 

    elif message.content.startswith("!invite"): # The !invite 
command emails the invite code to a specified email (ex. !invite 
[email protected]) 
     split = str(message.content).split() 
     recievingEmail = split[1] 
     content = ("email content goes here") 
     mail = smtplib.SMTP("smtp.gmail.com", 587) 
     mail.ehlo() 
     mail.starttls() 
     mail.login("sender email goes here", "sender email password 
goes here") 
     mail.sendmail("sender email goes here", recievingEmail, 
content) 
     mail.close() 
     await client.send_message(message.channel, "Invite code 
sent!") 


    elif message.content.startswith("!rand"): # The "!rand" command 
generates a random number between 1 and 100 
     randomNumber = str(random.randint(0, 100)) 
     response = ("Your random number is", randomNumber) 
     print(response) 
     await client.send_message(message.channel, response) 


    elif message.content.startswith("!help"): #send a direct message 
with a list of commands for things that the bot can do. 
     client.send_message(message.channel, "Here is a list of 
things that I can do: \n\n" 
     "!invite - Type '!invite insert email here' in the chat to 
send an email with an invite link to someone so that they can join 
the server.\n" 
     "!rand - Type '!rand' into the chat to generate a random 
number between 1 and 100.\n\n" 
     "Hope this helps!") 


#When a new user joins the server. 
@client.event 
async def on_member_join(member): # When a new member joins the 
server, the bot will send a direct message with some rules to them. 
    await client.send_message(member, "message content goes here") 


client.run("Discord Application Token goes here") 

がエラー:

Traceback (most recent call last): 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/aiohttp/connector.py", line 601, in _create_direct_connection 
    local_addr=self._local_addr) 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_events.py", line 803, in create_connection 
    sock, protocol_factory, ssl, server_hostname) 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_events.py", line 829, in _create_connection_transport 
    yield from waiter 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/sslproto.py", line 503, in data_received 
    ssldata, appdata = self._sslpipe.feed_ssldata(data) 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/sslproto.py", line 201, in feed_ssldata 
    self._sslobj.do_handshake() 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 689, in do_handshake 
    self._sslobj.do_handshake() 
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777) 

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

Traceback (most recent call last): 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/aiohttp/connector.py", line 304, in connect 
    yield from self._create_connection(req) 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/aiohttp/connector.py", line 578, in _create_connection 
    transport, proto = yield from self._create_direct_connection(req) 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/aiohttp/connector.py", line 624, in _create_direct_connection 
    (req.host, req.port, exc.strerror)) from exc 
aiohttp.errors.ClientOSError: [Errno 1] Can not connect to discordapp.com:443 [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)] 

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

Traceback (most recent call last): 
    File "bot-1025.py", line 70, in <module> 
    client.run("Discord Application Token goes here") 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/client.py", line 519, in run 
    self.loop.run_until_complete(self.start(*args, **kwargs)) 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_events.py", line 467, in run_until_complete 
    return future.result() 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/client.py", line 490, in start 
    yield from self.login(*args, **kwargs) 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/client.py", line 416, in login 
    yield from getattr(self, '_login_' + str(n))(*args, **kwargs) 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/client.py", line 346, in _login_1 
    data = yield from self.http.static_login(token, bot=is_bot) 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/http.py", line 258, in static_login 
    data = yield from self.request(Route('GET', '/users/@me')) 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/http.py", line 137, in request 
    r = yield from self.session.request(method, url, **kwargs) 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/aiohttp/client.py", line 555, in __iter__ 
    resp = yield from self._coro 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/aiohttp/client.py", line 198, in _request 
    conn = yield from self._connector.connect(req) 
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/aiohttp/connector.py", line 314, in connect 
    .format(key, exc.strerror)) from exc 
aiohttp.errors.ClientOSError: [Errno 1] Cannot connect to host discordapp.com:443 ssl:True [Can not connect to discordapp.com:443 [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)]] 
+3

ここにコードは掲載されていません。 – iBug

+1

[**コードやエラーの画像を投稿しないでください!**](https://meta.stackoverflow.com/q/303812/995714)画像とスクリーンショットは、投稿にはうってつけですが、ポストはそれがなければまだ明確かつ有用です。コードの画像やエラーメッセージを投稿する場合は、実際のコード/メッセージを直接コピーして貼り付けてください。 – Rob

+0

デバッグヘルプを求める質問(** "なぜこのコードは機能していませんか?" **)は、問題**の問題を再現するのに必要な最短コードを含める必要があります。** [mcve] – Rob

答えて

0

だから、私はいくつかのよりこの問題に見て、周り掘りの多くの後、私は働く解決策を見つけました。残念ながら、私はWindowsではなくMac用にこれを修正する方法しか知りません。あなたがしなければならないことは、アプリケーションのPython 3.6フォルダに移動し、Install Certificates.commandというファイルを実行することだけです。これが私のためにしたように初めて動作しない場合、あなたがしなければならないのは、同じコマンドをその前にsudoで実行することだけです。誰もが助けてくれてありがとう。

P.S. sudoコマンドは次のようになります。

sudo /Applications/Python\ 3.6/Install\ Certificates.command ; exit; 
関連する問題