質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Discord

Discordは、ゲーマー向けのボイスチャットアプリです。チャット・通話がブラウザ上で利用可能で、個人専用サーバーも開設できます。通話中でも音楽を流したり、PC画面を共有できるなど多機能な点が特徴です。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

解決済

1回答

3390閲覧

Pythonで作成したDiscordのBOTをterminalで起動できない。

PJwnOI

総合スコア39

Discord

Discordは、ゲーマー向けのボイスチャットアプリです。チャット・通話がブラウザ上で利用可能で、個人専用サーバーも開設できます。通話中でも音楽を流したり、PC画面を共有できるなど多機能な点が特徴です。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

1グッド

0クリップ

投稿2020/06/05 15:51

前提・実現したいこと

DiscordのBOTを作成し、動作させたい。

terminalで「Python3 Disco.py」と実行したところ、以下のエラーが出ました。
ものすごく多いです。

発生している問題・エラーメッセージ

terminal

1SSL handshake failed on verifying the certificate 2protocol: <asyncio.sslproto.SSLProtocol object at 0x109834080> 3transport: <_SelectorSocketTransport fd=10 read=polling write=<idle, bufsize=0>> 4Traceback (most recent call last): 5 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/sslproto.py", line 625, in _on_handshake_complete 6 raise handshake_exc 7 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/sslproto.py", line 189, in feed_ssldata 8 self._sslobj.do_handshake() 9 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 763, in do_handshake 10 self._sslobj.do_handshake() 11ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056) 12SSL error in data received 13protocol: <asyncio.sslproto.SSLProtocol object at 0x109834080> 14transport: <_SelectorSocketTransport closing fd=10 read=idle write=<idle, bufsize=0>> 15Traceback (most recent call last): 16 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/sslproto.py", line 526, in data_received 17 ssldata, appdata = self._sslpipe.feed_ssldata(data) 18 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/sslproto.py", line 189, in feed_ssldata 19 self._sslobj.do_handshake() 20 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 763, in do_handshake 21 self._sslobj.do_handshake() 22ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056) 23SSL handshake failed on verifying the certificate 24protocol: <asyncio.sslproto.SSLProtocol object at 0x10983e908> 25transport: <_SelectorSocketTransport fd=10 read=polling write=<idle, bufsize=0>> 26Traceback (most recent call last): 27 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/sslproto.py", line 625, in _on_handshake_complete 28 raise handshake_exc 29 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/sslproto.py", line 189, in feed_ssldata 30 self._sslobj.do_handshake() 31 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 763, in do_handshake 32 self._sslobj.do_handshake() 33ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056) 34SSL error in data received 35protocol: <asyncio.sslproto.SSLProtocol object at 0x10983e908> 36transport: <_SelectorSocketTransport closing fd=10 read=idle write=<idle, bufsize=0>> 37Traceback (most recent call last): 38 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/sslproto.py", line 526, in data_received 39 ssldata, appdata = self._sslpipe.feed_ssldata(data) 40 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/sslproto.py", line 189, in feed_ssldata 41 self._sslobj.do_handshake() 42 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 763, in do_handshake 43 self._sslobj.do_handshake() 44ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056) 45SSL handshake failed on verifying the certificate 46protocol: <asyncio.sslproto.SSLProtocol object at 0x10984aba8> 47transport: <_SelectorSocketTransport fd=10 read=polling write=<idle, bufsize=0>> 48Traceback (most recent call last): 49 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/sslproto.py", line 625, in _on_handshake_complete 50 raise handshake_exc 51 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/sslproto.py", line 189, in feed_ssldata 52 self._sslobj.do_handshake() 53 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 763, in do_handshake 54 self._sslobj.do_handshake() 55ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056) 56SSL error in data received 57protocol: <asyncio.sslproto.SSLProtocol object at 0x10984aba8> 58transport: <_SelectorSocketTransport closing fd=10 read=idle write=<idle, bufsize=0>> 59Traceback (most recent call last): 60 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/sslproto.py", line 526, in data_received 61 ssldata, appdata = self._sslpipe.feed_ssldata(data) 62 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/sslproto.py", line 189, in feed_ssldata 63 self._sslobj.do_handshake() 64 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 763, in do_handshake 65 self._sslobj.do_handshake() 66ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056) 67SSL handshake failed on verifying the certificate 68protocol: <asyncio.sslproto.SSLProtocol object at 0x10984acf8> 69transport: <_SelectorSocketTransport fd=10 read=polling write=<idle, bufsize=0>> 70Traceback (most recent call last): 71 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/sslproto.py", line 625, in _on_handshake_complete 72 raise handshake_exc 73 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/sslproto.py", line 189, in feed_ssldata 74 self._sslobj.do_handshake() 75 76あまりにも長すぎて投稿できないので省略 77 78 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 763, in do_handshake 79 self._sslobj.do_handshake() 80ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056) 81SSL error in data received 82protocol: <asyncio.sslproto.SSLProtocol object at 0x10984acf8> 83transport: <_SelectorSocketTransport closing fd=10 read=idle write=<idle, bufsize=0>> 84Traceback (most recent call last): 85 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/sslproto.py", line 526, in data_received 86 ssldata, appdata = self._sslpipe.feed_ssldata(data) 87 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/sslproto.py", line 189, in feed_ssldata 88 self._sslobj.do_handshake() 89 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 763, in do_handshake 90 self._sslobj.do_handshake() 91ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056) 92SSL handshake failed on verifying the certificate 93protocol: <asyncio.sslproto.SSLProtocol object at 0x10984ae48> 94transport: <_SelectorSocketTransport fd=10 read=polling write=<idle, bufsize=0>> 95Traceback (most recent call last): 96 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/sslproto.py", line 625, in _on_handshake_complete 97 raise handshake_exc 98 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/sslproto.py", line 189, in feed_ssldata 99 self._sslobj.do_handshake() 100 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 763, in do_handshake 101 self._sslobj.do_handshake() 102ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056) 103SSL error in data received 104protocol: <asyncio.sslproto.SSLProtocol object at 0x10984ae48> 105transport: <_SelectorSocketTransport closing fd=10 read=idle write=<idle, bufsize=0>> 106Traceback (most recent call last): 107 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/sslproto.py", line 526, in data_received 108 ssldata, appdata = self._sslpipe.feed_ssldata(data) 109 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/sslproto.py", line 189, in feed_ssldata 110 self._sslobj.do_handshake() 111 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 763, in do_handshake 112 113 114 115 116あまりにも長すぎて投稿できないので省略 117 118 119 120aiohttp.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:1056)')] 121

該当のソースコード

Python

1import discord 2 3client = discord.Client() 4token = "????????????????????????????????????????????????A" 5#tokenは隠しておきます。 6@client.event 7async def on_ready(): 8 print('Logged in as') 9 print(client.user.name) 10 print(client.user.id) 11 print('------') 12 13@client.event 14async def on_message(message): 15 # 「おはよう」で始まるか調べる 16 if message.content.startswith("おはよう"): 17 # 送り主がBotだった場合反応したくないので 18 if client.user != message.author: 19 # メッセージを書きます 20 m = "おはようございます" + message.author.name + "!" 21 # メッセージが送られてきたチャンネルへメッセージを送ります 22 await message.channel.send(m) 23 24client.run(token)

試したこと

discord.pyを再インストールしましたが、変わりませんでした。

補足情報

macOS Catalina Ver 10.15.4
Python3.7

teamikl👍を押しています

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

windowsですが先日同じ様なエラーに遭遇しました
SSL証明書の期限切れらしいです。


macOS の場合(試してませんが見かけた情報)

補足事項
FAQ: 実行時に SSLError が発生します

$ /Applications/Python\ 3.7/Install\ Certificates.command

Windowsの場合

(情報元失念、githubかstackoverflowだったと思います。手元メモより)

To answer your question, the Root CA from Discord's certificate vendor expired on May 30th. You will need to manually download the new certificate here (Look for 'Download certificate PEM') and install it to your local computer until Windows has an update to correct this issue.

To fix this:

  • Go to discord.com with IE (Ran as Administrator)
  • Click the lock on the top right
  • Click view certificates
  • Install one

ブラウザで discord.com のサイトに行って
鍵マークのアイコンから証明書をダウンロード&インストール。
で自分の場合は解決できました。

投稿2020/06/05 16:41

teamikl

総合スコア8664

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

PJwnOI

2020/06/06 15:18

貼ってくださったリンクはすでに見ていたのですが、気付きませんでした。私も解決できました!ありがとうございました!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問