zoukankan      html  css  js  c++  java
  • python之vscode配置开发调试环境

    在vscode中下载python插件,下载量最多的就是
    打开launch.json,把以下代码粘贴进去即可
    {
        // 使用 IntelliSense 了解相关属性。 
        // 悬停以查看现有属性的描述。
        // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
        "version": "0.2.0",
        "configurations": [
            {
                "name": "Python",
                "type": "python",
                "request": "launch",
                "stopOnEntry": false,//是否在第一条语句时程序停止,下面的这个选项都一样
                "pythonPath": "D:/Program Files (x86)/Python37-32/python",//设置成自己的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"
            }
        ]
    }
    
    在settings.json中加上以下代码:
    "python.pythonPath": "D:\Program Files (x86)\Python37-32\python" , //自己的python安装路径
    "python.linting.enabled": false,
    

    以上代码亲测有效,另附https://www.cnblogs.com/qdscwyy/p/7756694.html

  • 相关阅读:
    性能优化方法
    JSM的topic和queue的区别
    关于分布式事务、两阶段提交协议、三阶提交协议
    大型网站系统与Java中间件实践读书笔记
    Kafka设计解析:Kafka High Availability
    kafka安装和部署
    String和intern()浅析
    JAVA中native方法调用
    Java的native方法
    happens-before俗解
  • 原文地址:https://www.cnblogs.com/raind/p/10119390.html
Copyright © 2011-2022 走看看