Seite 1 von 1

DiscordBot 3.7

Verfasst: Donnerstag 21. Februar 2019, 17:38
von Niwla23
https://www.youtube.com/watch?v=EXuwcQZQ5Fs
wie geht das in python 3.7?
Code:

Code: Alles auswählen

from discord.ext import commands


client = commands.Bot(command_prefix="+")


@client.event
async def on_ready():
    print("Bot ist Bereit")


client.run("TOKEN")
Fehler:

Code: Alles auswählen

/home/alwin/PycharmProjects/DiscordBot/venv/bin/python /home/alwin/PycharmProjects/DiscordBot/bot.py
Traceback (most recent call last):
  File "/home/alwin/PycharmProjects/DiscordBot/bot.py", line 1, in <module>
    from discord.ext import commands
  File "/home/alwin/PycharmProjects/DiscordBot/venv/lib/python3.7/site-packages/discord/__init__.py", line 20, in <module>
    from .client import Client, AppInfo, ChannelPermissions
  File "/home/alwin/PycharmProjects/DiscordBot/venv/lib/python3.7/site-packages/discord/client.py", line 38, in <module>
    from .state import ConnectionState
  File "/home/alwin/PycharmProjects/DiscordBot/venv/lib/python3.7/site-packages/discord/state.py", line 36, in <module>
    from . import utils, compat
  File "/home/alwin/PycharmProjects/DiscordBot/venv/lib/python3.7/site-packages/discord/compat.py", line 32
    create_task = asyncio.async
                              ^
SyntaxError: invalid syntax

Process finished with exit code 1
viele grüße Niwla23
PS: Ich nutze Pycharm mit VirtualEnv

Re: DiscordBot 3.7

Verfasst: Donnerstag 21. Februar 2019, 18:41
von Tholo
So sagt Google
https://github.com/Rapptz/discord.py/issues/1249
https://github.com/Rapptz/discord.py/issues/1401

Code: Alles auswählen

pip3 install git+https://github.com/Rapptz/discord.py@rewrite
Ich hab das nicht getestet aber StackOverflow und Github ist voll damit.
Oder das hier

Code: Alles auswählen

create_task = asyncio.async 
zu

Code: Alles auswählen

create_task = getattr(asyncio, 'async')

Re: DiscordBot 3.7

Verfasst: Freitag 22. Februar 2019, 13:47
von Niwla23
Hmm, pip3 spuckt einen Fehler aus und das hier auch:

Code: Alles auswählen

from discord.ext import commands


client = commands.Bot(command_prefix="+")



@client.event
create_task = getattr(asyncio, "async")
async def on_ready():
    print("Bot ist Bereit")


client.run("NTQTOKENDgwMjYTOKENexfHZGzDaTOKENo")

Code: Alles auswählen

/home/alwin/PycharmProjects/DiscordBot/venv/bin/python /home/alwin/PycharmProjects/DiscordBot/bot.py
  File "/home/alwin/PycharmProjects/DiscordBot/bot.py", line 9
    create_task = getattr(asyncio, "async")
              ^
SyntaxError: invalid syntax

Process finished with exit code 1

Re: DiscordBot 3.7

Verfasst: Freitag 22. Februar 2019, 14:20
von __blackjack__
@Niwla23: Wenn ``pip3`` einen Fehler ausspuckt, dann gibt es wohl ein Problem. Mehr kann man da nicht sagen ohne zu wissen was Du genau gemacht hast und was da genau passiert ist.

Warum Du jetzt in *Deinen* Quelltext ``create_task = getattr(asyncio, "async")`` geschrieben hast und das dann auch noch an einer Stelle wo es ein Syntaxfehler ist, müsstest Du mal erklären. :-)

Re: DiscordBot 3.7

Verfasst: Freitag 22. Februar 2019, 14:25
von Niwla23
Ich weiß ja nicht wo diese codezeile hinmuss. Ich habe es halt d aprobiert, wo muss sie denn hin oder ist das was anderes?

Re: DiscordBot 3.7

Verfasst: Freitag 22. Februar 2019, 17:40
von __blackjack__
@Niwla23: Tholo hat doch nicht nur diese Zeile gezeigt sondern auch geschrieben anstelle welcher Zeile die stehen müsste also welche Zeile man damit *ersetzen* müsste. Und wenn Du Dir den Traceback noch einmal anschaust, siehst Du das es die Zeile ist über die der Compiler stolpert, und da sieht man ja auch *wo* die Originalzeile ist.

Re: DiscordBot 3.7

Verfasst: Freitag 22. Februar 2019, 19:19
von Niwla23
Ich glaub ich bin zu doof, wo soll ich das jetzt einfügen???

Re: DiscordBot 3.7

Verfasst: Freitag 22. Februar 2019, 20:06
von sparrow
Tholo hat dir gezeigt, welche Zeile zu ersetzen ist.
Die findet sich, inklusive Datei und Zeilenangabe, in deinem ersten gezeigten Traceback.

Re: DiscordBot 3.7

Verfasst: Freitag 22. Februar 2019, 23:02
von Niwla23
Problem halb gelöst: Raspi benutzen = python 2.7 3.5

Re: DiscordBot 3.7

Verfasst: Sonntag 24. Februar 2019, 17:35
von Tholo
Nur mit nem Pi machst du es nicht besser. Schau dir doch mal den Stockoverflow oder github Post an, welche ich oben gepostet hab. Ich hab dir da googeln nun schon abgenommen. Noch mehr kann man ja nicht mit Zäunen schmeißen

Re: DiscordBot 3.7

Verfasst: Sonntag 24. Februar 2019, 20:07
von DeaD_EyE
Niwla23 hat geschrieben: Freitag 22. Februar 2019, 23:02 Problem halb gelöst: Raspi benutzen = python 2.7 3.5
Gut, bis zum Jahr 2020 hast du das Problem "gelöst".

async ist ein Schlüsselwort seit 3.7 und du kannst es nicht als Namen für irgendetwas verwenden.
Der wir nun mal im Quellcode verwendet (nicht in deinem). Der Fehler bleibt so lange bestehen, bis im Quellcode der Name async nach irgendwas andere umbennat wird.