0

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.

Akorian
  • 85
  • 6

2 Answers2

1

You have two different errors:

  1. python oasis_live.py most likely is the python2.7 interpreter and the syntax is incompatible
  2. python3 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 called discord. To use that, you need to install it first, e.g. with pip3 install discord
Maurice
  • 11,482
  • 2
  • 25
  • 45
1

You probably need to install the dependencies on the EC2 Instance too. Try to pip install all the dependencies that you need. Including discord (pip install discord)