Skip to content
Advertisement

Discord Python Raspbian Error invalid syntax when running script

This is my first time writing in this platform. I got an error on my RPi when hosting a discord music bot using lavalink. Currently, my problem is that there’s a invalid syntax error on a line of code. The weird part is that I don’t get this error when I use VSCode on Windows 10. It also ran perfect in Win 10. I’ve tried to install the required packages, tried to search up what could be the problem. I found no results. I was wondering what could be my main issue over here.

Main src code:

JavaScript

Console Error:

JavaScript

Not to mention my RPi is running Raspbian x64.

Advertisement

Answer

The := syntax (i.e., the assignment expression) was introduced in Python 3.8 (see, e.g., https://docs.python.org/3/whatsnew/3.8.html), and according to the traceback you’ve shared, you’re running Python 3.7.

If you want your script to run on this older version, you’ll have to rewrite it to not use this syntax. For example, you could extract the assignment out of the if‘s condition:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement