I get an error `Invalid Syntax`

python

#1

Hi,
i am having a problem with c9. I am creating a bot for a service using Python. The code works fine on my computer, but when I try to use it on c9, I get the following error:

File "bot.py", line 7
async def on_ready():
    ^
SyntaxError: invalid syntax

Why is that? Please help.
Thanks in advance


#2

What version of python are you using locally? You may need to update python on c9.


#3

If your bot is written in Python 3, try running it with python3 command instead.


#4

I have tried both - same error


#5

It’s tough to tell what the issue is with the information you’ve given. Can you include some of your code so we can see what might be going on? If your workspace is public you could include a link to the workspace as well.


#6

I’m getting this same error. The problem is defining asynchronous functions in python 3.6. The code that is causing this problem for both of us is:

@client.event
async def on_ready():
print(‘Logged in as’)
print(client.user.name)
print(client.user.id)
print(’------’)

This code is for the on_ready event for a discord python bot. If I remove this function, I get the same error on my next function.