环境
作为多根工作区的一部分,我在 VS Code 中有一个 Python 快速入门。我手动添加了 3 个文件;tasks.json、settings.json和launch.json。
意外行为
当我调试项目时,主脚本由于缺少模块而失败。这是因为在启动时未安装requirements.txt中列出的模块。
任务.json
{
"version": "2.0.0",
"tasks": [
{
"label": "pipInstall",
"type": "shell",
"osx": {
"command": "${config:python.pythonPath}/bin/python -m pip install -r requirements.txt"
},
"windows": {
"command": "${config:python.pythonPath}\\Scripts\\python -m pip install -r requirements.txt"
},
"linux": {
"command": "${config:python.pythonPath}/bin/python -m pip install -r requirements.txt"
},
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}"
}
}
]
}
启动.json
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}\\batch-python-quickstart\\src\\python_quickstart_client.py",
"console": "integratedTerminal"
}
]
}
设置.json
{
"python.pythonPath": "C:\\Python Virtual Environments\\myenvid\\.venv\\Scripts\\python.exe"
}
心有法竹
相关分类