首页 > 编程 > Python > 正文

VSCode下配置python调试运行环境的方法

2020-02-22 23:37:01
字体:
来源:转载
供稿:网友

VSCode配置python调试环境

很久之前的一个东东,翻出来看看

VSCode配置python调试环境
* 1.下载python解释器
* 2.在VSCode市场中安装Python插件
* 4.在用户设置里加两条
* 5.接下来是正式的调试了 1080 两个数的平方和 Input Output Input示例 Output示例

1.下载python解释器

python 3.6.3 for windows

安装到系统某个路径例如C:/Python36
最好添加到Path,也可以不加

2.在VSCode市场中安装Python插件

python插件

3.同样是打开一个文件夹,新建一个.py文件(这样容易识别项目,vscode就需要新建一个文件夹)
4.同样是launch.json文件和tasks.json文件

launch.josn

{ // 使用 IntelliSense 了解相关属性。  // 悬停以查看现有属性的描述。 // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [  {   "name": "Python",   "type": "python",   "request": "launch",   "stopOnEntry": false,//是否在第一条语句时程序停止,下面的这个选项都一样   "pythonPath": "C:/Python34/python",//可执行文件路径   "program": "${file}",   "cwd": "${workspaceRoot}",   "env": {},   "envFile": "${workspaceRoot}/.env",   "debugOptions": [    "WaitOnAbnormalExit",    "WaitOnNormalExit",    "RedirectOutput"   ]  },  {   "name": "PySpark",   "type": "python",   "request": "launch",   "stopOnEntry": true,   "osx": {    "pythonPath": "${env:SPARK_HOME}/bin/spark-submit"   },   "windows": {    "pythonPath": "${env:SPARK_HOME}/bin/spark-submit.cmd"   },   "linux": {    "pythonPath": "${env:SPARK_HOME}/bin/spark-submit"   },   "program": "${file}",   "cwd": "${workspaceRoot}",   "env": {},   "envFile": "${workspaceRoot}/.env",   "debugOptions": [    "WaitOnAbnormalExit",    "WaitOnNormalExit",    "RedirectOutput"   ]  },  {   "name": "Python Module",   "type": "python",   "request": "launch",   "stopOnEntry": false,   "pythonPath": "${config:python.pythonPath}",   "module": "module.name",   "cwd": "${workspaceRoot}",   "env": {},   "envFile": "${workspaceRoot}/.env",   "debugOptions": [    "WaitOnAbnormalExit",    "WaitOnNormalExit",    "RedirectOutput"   ]  },  {   "name": "Integrated Terminal/Console",   "type": "python",   "request": "launch",   "stopOnEntry": false,   "pythonPath": "${config:python.pythonPath}",   "program": "${file}",   "cwd": "",   "console": "integratedTerminal",   "env": {},   "envFile": "${workspaceRoot}/.env",   "debugOptions": [    "WaitOnAbnormalExit",    "WaitOnNormalExit"   ]  },  {   "name": "External Terminal/Console",   "type": "python",   "request": "launch",   "stopOnEntry": false,   "pythonPath": "${config:python.pythonPath}",   "program": "${file}",   "cwd": "",   "console": "externalTerminal",   "env": {},   "envFile": "${workspaceRoot}/.env",   "debugOptions": [    "WaitOnAbnormalExit",    "WaitOnNormalExit"   ]  },  {   "name": "Django",   "type": "python",   "request": "launch",   "stopOnEntry": false,   "pythonPath": "${config:python.pythonPath}",   "program": "${workspaceRoot}/manage.py",   "cwd": "${workspaceRoot}",   "args": [    "runserver",    "--noreload",    "--nothreading"   ],   "env": {},   "envFile": "${workspaceRoot}/.env",   "debugOptions": [    "WaitOnAbnormalExit",    "WaitOnNormalExit",    "RedirectOutput",    "DjangoDebugging"   ]  },  {   "name": "Flask",   "type": "python",   "request": "launch",   "stopOnEntry": false,   "pythonPath": "${config:python.pythonPath}",   "program": "fully qualified path fo 'flask' executable. Generally located along with python interpreter",   "cwd": "${workspaceRoot}",   "env": {    "FLASK_APP": "${workspaceRoot}/quickstart/app.py"   },   "args": [    "run",    "--no-debugger",    "--no-reload"   ],   "envFile": "${workspaceRoot}/.env",   "debugOptions": [    "WaitOnAbnormalExit",    "WaitOnNormalExit",    "RedirectOutput"   ]  },  {   "name": "Flask (old)",   "type": "python",   "request": "launch",   "stopOnEntry": false,   "pythonPath": "${config:python.pythonPath}",   "program": "${workspaceRoot}/run.py",   "cwd": "${workspaceRoot}",   "args": [],   "env": {},   "envFile": "${workspaceRoot}/.env",   "debugOptions": [    "WaitOnAbnormalExit",    "WaitOnNormalExit",    "RedirectOutput"   ]  },  {   "name": "Pyramid",   "type": "python",   "request": "launch",   "stopOnEntry": true,   "pythonPath": "${config:python.pythonPath}",   "cwd": "${workspaceRoot}",   "env": {},   "envFile": "${workspaceRoot}/.env",   "args": [    "${workspaceRoot}/development.ini"   ],   "debugOptions": [    "WaitOnAbnormalExit",    "WaitOnNormalExit",    "RedirectOutput",    "Pyramid"   ]  },  {   "name": "Watson",   "type": "python",   "request": "launch",   "stopOnEntry": true,   "pythonPath": "${config:python.pythonPath}",   "program": "${workspaceRoot}/console.py",   "cwd": "${workspaceRoot}",   "args": [    "dev",    "runserver",    "--noreload=True"   ],   "env": {},   "envFile": "${workspaceRoot}/.env",   "debugOptions": [    "WaitOnAbnormalExit",    "WaitOnNormalExit",    "RedirectOutput"   ]  },  {   "name": "Attach (Remote Debug)",   "type": "python",   "request": "attach",   "localRoot": "${workspaceRoot}",   "remoteRoot": "${workspaceRoot}",   "port": 3000,   "secret": "my_secret",   "host": "localhost"  } ]}            
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表