So, I'm trying to write a bot for a discord server, using discord.py as an API wrapper. I'm trying to use my Raspberry Pi 2 B as a server to run it. I have jessie and python 3.4 installed on the device, as well as some modules for python. The imported modules in my code are discord, asyncio, and datetime. However, when I try to run my bot, which works perfectly on my mac, I get this error message:

File "BotTest.py", line 8
    async def on_ready():

SyntaxError: invalid syntax

For reference: this is a sample of the code I'm using:

import discord
import asyncio
import datetime

bot = discord.Client()

async def on_ready():
    print('Logged in as')
    print(bot.user.name, bot.user)
    print([c.name for c in bot.get_all_channels()])


The 'Bot-User-Token' is, of course, replaced by the actual user token in the full code. The only other part of the code is a function defined with 'async def on_message(message):', so it would be affected by the same issue.


3 Answers 3


I believe async and await are for python 3.5, I think you'll need to use the @asyncio.coroutine decorator for async def and yield from for await in python 3.4


from version 3.4 asycn and await are reserved keywords

like the error in below image

enter image description here

copy the link up to directory/folder name( not include init.py) you will get a list of .py files enter image description here

rename async file to _async or asynch or anything u want as async is now a reserved keyword with us from version 3.4

once renamed than open check in all files where we have import async modify the new name every where

and enjoy

  • It looks like the OP intended to use the reserved syntax in order to use async functions; in this case there is no clashing module as in your images. The accepted answer has the actual issue and solution here.
    – Aurora0001
    Aug 21, 2018 at 17:39

You could just do python3 <yourbot>.py since it uses python3

edit: for this to work you need to do make sure python3 has discord.py by using pip3 install discord-rewrite and your code would have to be written with discord rewrite modules.

  • 2
    As tobyd's answer points out, async and await aren't supported until Python 3.5, but the question says that Python 3.4 is installed. Running python3 <yourbot>.py will just run the Python 3.4 version which doesn't work, unfortunately. Perhaps you could explain how to make sure you have Python 3.5 which will work?
    – Aurora0001
    Aug 31, 2018 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.