SyntaxError: invalid syntax

Python 3.8.2 is loaded on Levono Think Station running Windows 10. I run the code below and get “Syntax Error: invalid syntax”. I get the same error for anything I run.

I looked at a similar topic which said a “:” is missing. However, the author did not say where the missing colon should go.

Does anyone know what is wrong? or where the missing colon goes?

sudo apt-get install build-essential checkinstall sudo apt-get install

John DeBaise

Photo too vague.
You may print out the code instead.

Welcome, jd.

As montanio said, it is very difficult for us to help/work-with code in a screenshot. Please either edit your post, or add a reply to include your code in the MarkDown syntax:

When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.


As above, please post the actual text, not photos of text.

But it seems pretty clear that you’re getting the error because you’re trying to run a series of apt-get commands in a Python shell in a Windows terminal.

sudo is a Linux command-line program for allowing a user to use the privileges of another user (in this case the root account, to allow installation).

apt is a Linux command-line tool for installing/updating/etc software.

sudo apt-get someprogram is “switch to root user and run the apt-get command to install someprogram”

So you are:

  1. Opening a windows command prompt
  2. running python to open an interactive Python shell (where you can type Python code and evaluate it)
  3. attempting to use the Linux package management tool to download Linux system utilities.

This is not Python code in any way, there is no way this will do anything except error. This is not a Linux computer, so even if you could install from the Python shell, how is it going to install anything?

You can use the Windows Subsystem for Linux to open a bash shell where you can install linux command-line utilities. You can also open a Python shell there. You can’t install system utilies on a python shell: it’s like expecting to be able to install a Windows program from it: it’s not going to work.

In addition, you’ve copy pasted the commands all in one line instead of seperate lines, so you are attempting to switch to super user to run apt-get to get a series of packages (space seperated), which include sudo and apt-get multiple times (on a linux system sudo is already installed and apt-get is a command, not an installable program).

Hi Dan,
Thanks for your reply. The code in my came from the book, “Python for beginners” by PROGRAMMING LANGUAGES ACADEMY. I found it on Amazon (Kindle Book). It is certainly written for Python using the Windows platform. I am just getting started with Python. I’m an engineer by trade. Obviously, I have much less knowledge than you. I must say, I am very impressed with the number of and timely responses from you folks at “freeCodeCamp”. I am happy I joined and hope to have a long relationship.
John DeBaise