`SyntaxError: Ungültiges Syntax
Posted: 11 Feb 2025, 04:59
Ich versuche, ein Python -Skript aus dem Visual Studio -Code auszuführen, aber das Skript kann nicht ausgeführt werden und stürzt mit einem SyntaxError nicht aus, der auf den Kommentar zu Beginn von Start.json .
:
:
Datei über Python und // ist eine ungültige Kommentarsyntax in Python. Wenn ich die Kommentare entferne, erhalte ich diesen Fehler: < /p>
Wenn ich Pythons false verwende, stürze ich nicht, aber nichts passiert und mein Skript wird nicht ausgeführt. Es scheint sehr ähnlich zu sein, dass Start.json von Python fälschlicherweise analysiert wird. Irgendeine Fix dafür?
Code: Select all
launch.json
Code: Select all
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python | Default",
"type": "python",
"request": "launch",
"stopOnEntry": false,
"pythonPath": "${config:python.pythonPath}",
"program": "${file}",
"cwd": "${workspaceFolder}",
"env": {},
"envFile": "${workspaceFolder}/.env",
"debugOptions": [
"RedirectOutput"
]
}
]
}
< /code>
Terminalausgabe: < /p>
File ".../.vscode/launch.json", line 2
// Use IntelliSense to learn about possible attributes.
^
SyntaxError: invalid syntax
< /code>
settings.json
Code: Select all
{
"python.pythonPath": "${workspaceFolder}/venv/bin/python"
}
< /code>
I was working on my Windows machine earlier and all of this worked perfectly fine. For some reason, VSCode is trying to run the launch.json
Code: Select all
Traceback (most recent call last):
File ".../.vscode/launch.json", line 8, in
"stopOnEntry": false,
NameError: name 'false' is not defined