问题:manage.py中的VS Code调试器,在django中启动新项目时会生成这些代码
修改
实际错误:
user@user:~/PROJ/py/lib$ cd /home/user/PROJ/py/lib ; env "PYTHONIOENCODING=UTF-8" "PYTHONUNBUFFERED=1" python /home/user/.vscode/extensions/ms-python.python-2018.3.1/pythonFiles/PythonTools/visualstudio_py_launcher.py /home/user/PROJ/py/lib 42135 34806ad9-833a-4524-8cd6-18ca4aa74f14 RedirectOutput,RedirectOutput,DjangoDebugging /home/user/PROJ/py/lib/manage.py runserver --noreload --nothreading
File "/home/user/PROJ/py/lib/manage.py", line 14
) from exc
^
SyntaxError: invalid syntax
manage.py:
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "lib.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
这是我在launch.json中的配置:
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": [
"runserver",
"--noreload",
"--nothreading"
],
"debugOptions": [
"RedirectOutput",
"Django",
]
}