Issue
I am trying to run a python file on an EC2 machine with Amazon Linux installed. I used putty to connect and when I try to run the file I get this output.
[ec2-user@myIP ~]$ python oasis_live.py
File "oasis_live.py", line 36
async def on_ready(self):
^
SyntaxError: invalid syntax
[ec2-user@myIP ~]$ python3 oasis_live.py
Traceback (most recent call last):
File "oasis_live.py", line 3, in <module>
import discord
ModuleNotFoundError: No module named 'discord'
[ec2-user@myIP ~]$
This is very confusing to me since the code works perfectly fine on my PC.
Solution
You have two different errors:
python oasis_live.py
most likely is the python2.7 interpreter and the syntax is incompatiblepython3 oasis_live.py
is the python3.x interpreter, which probably is the one you want to use since you use async functions. Your code seems to rely on a 3rd party dependency calleddiscord
. To use that, you need to install it first, e.g. withpip3 install discord
Answered By - Maurice Answer Checked By - Willingham (WPSolving Volunteer)