I did all the steps in the video below: https://www.youtube.com/watch?v=qobogVuXtJU&list=PLbGkCPlkC_XTAUG5HC1WPhxMuZQnBQ7jU&index=1&t=308s

When I run the full Python file, it throws this:

File "<stdin>", line 1
    & C:/PROGRA~1/QGIS32~1.3/bin/python.exe e:/ELTE_TTK_mesterkepzes/3_felev/Terinformatics_problem_solutions/Venyige/eszkoz/proba.py       
SyntaxError: invalid syntax

This is my code at the moment:

from qgis.core import QgsApplication

QgsApplication.setPrefixPath("/path/to/qgis/installation", True) # Set the path to QGIS
qgs = QgsApplication([], False)

When I run it line by line with Shift+Enter, it prints the same lines at the bottom in Terminal but does nothing anyway.

All tool names and variables are good highlights, so I don't know what the problem is.

  • If you would be familiar with conda, there is a qgis package in the conda-forge channel, and I have good experiences using pyqgis this way.
    – Pieter
    Commented Nov 28, 2023 at 21:17

1 Answer 1


It seems like python is allready running. When you try to start python with C:/PROGRA~1/QGIS32~1.3/bin/python.exe you get the syntax error, because you cant start python in the console when its allready running in the same console.

You can easily reproduce it: Just make an easy script with print('Hello World'). Start it and it will run without problems. Go in the console in VS Code and type python. Now python is running in the console and you can make normal python statements. Now run your Hello-World-Script again. You will get an error like the one you described in you question.

That should be solved very easy: Just type exit() into your console, where the error appears and run your code again. Alternatively you can click the bin-symbol in the vs-code-console and kill it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.