欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

python and VScode 博客分类: 软件安装自动化测试 pythonvscodetasks.jsonlaunch.json 

程序员文章站 2024-03-18 21:11:58
...

 

 mac 下vscode配置python

 

  • command + shift + P 输入task

 

python and VScode
            
    
    博客分类: 软件安装自动化测试 pythonvscodetasks.jsonlaunch.json 

 

  • 打开第一个配置文件tasks.json

python and VScode
            
    
    博客分类: 软件安装自动化测试 pythonvscodetasks.jsonlaunch.json 

    •  {   "version": "0.1.0",
          "command": "python",
          "isShellCommand": true,
          "args": ["${file}"],
          "showOutput": "always"
      }
       
    • 新建一个test.py
    • command + shift + B运行py文件

    • python and VScode
            
    
    博客分类: 软件安装自动化测试 pythonvscodetasks.jsonlaunch.json 
       
      •  配置python debug
      • 1、新建一个python项目
      • 2、打开launch.json文件
      • python and VScode
            
    
    博客分类: 软件安装自动化测试 pythonvscodetasks.jsonlaunch.json 
  •  3、修改lanuch.json文件为:
  • {
        "version": "0.2.0",
        "configurations": [
    
            {
                "name": "Python",
                "type": "python",
                "request": "launch",
                "stopOnEntry": true,
                "pythonPath": "${config:python.pythonPath}",
                "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": true,
                "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": true,
                "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": true,
                "pythonPath": "${config:python.pythonPath}",
                "program": "${file}",
                "cwd": "",
                "console": "externalTerminal",
                "env": {},
                "envFile": "${workspaceRoot}/.env",
                "debugOptions": [
                    "WaitOnAbnormalExit",
                    "WaitOnNormalExit"
                ]
            },
            {
                "name": "Django",
                "type": "python",
                "request": "launch",
                "stopOnEntry": true,
                "pythonPath": "${config:python.pythonPath}",
                "program": "${workspaceRoot}/manage.py",
                "cwd": "${workspaceRoot}",
                "args": [
                    "runserver",
                    "--noreload"
                ],
                "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"
            }
        ]
    }
  • 4、debug窗口就会出现python debug 字样,就可以直接debug了;

  • python and VScode
            
    
    博客分类: 软件安装自动化测试 pythonvscodetasks.jsonlaunch.json 
     完毕!
  • python and VScode
            
    
    博客分类: 软件安装自动化测试 pythonvscodetasks.jsonlaunch.json 
  • 大小: 52.9 KB
  • python and VScode
            
    
    博客分类: 软件安装自动化测试 pythonvscodetasks.jsonlaunch.json 
  • 大小: 41 KB
  • python and VScode
            
    
    博客分类: 软件安装自动化测试 pythonvscodetasks.jsonlaunch.json 
  • 大小: 41.5 KB
  • python and VScode
            
    
    博客分类: 软件安装自动化测试 pythonvscodetasks.jsonlaunch.json 
  • 大小: 41.7 KB
  • python and VScode
            
    
    博客分类: 软件安装自动化测试 pythonvscodetasks.jsonlaunch.json 
  • 大小: 41.7 KB