Reputation: 41
(Using Python 3.6)
Hello !
I'm actually making a Python Discord bot (for a school project) and i'm facing a little problem at this part of the code:
async def on_message(self, message):
if not message.author.bot:
ctx = await bot.get_context(message)
await self.invoke(ctx)
Here is the error message:
File "/Users/dorian/Desktop/ISN/ISNbotv2/bot.py", line 47
async def on_message(self, message):
^
SyntaxError: invalid syntax
[Finished in 0.1s with exit code 1]
[shell_cmd: python -u "/Users/dorian/Desktop/ISN/ISNbotv2/bot.py"]
[dir: /Users/dorian/Desktop/ISN/ISNbotv2]
[path:
/Library/Frameworks/Python.framework/Versions/3.6/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]
Weirdly when I launch the script with my PC the bot is working, unfortunatly I only have this error only on the MAC I HAVE to use for my school project.
Thanks for your help (and sorry if I made english mistakes, not my main langage)
Upvotes: 2
Views: 6466
Reputation: 3755
To double check your version via script. import sys; print(sys.version)
People usually install python 3.7 on top of existing python 2.x that is with the system. When running a command sometimes you will forget to run it as python3.7 instead of just simply python which would run python2.
Therefore it causes the error "Async def invalid syntax"
Run python3.7
Upvotes: 1