博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mac vscode Python配置
阅读量:6531 次
发布时间:2019-06-24

本文共 7158 字,大约阅读时间需要 23 分钟。

配置编辑器

1. 基础设置settings.json

VS Code有很多选项可以来配置编辑器,你可以通过用户设置来设置全局选项,或在工作空间设置中针对每个文件夹或项目设置,选项设置保存在settings.json 文件中。

Files > Preferences > User Settings (或者按下 kb(workbench.action.showCommands), 输入 user 然后按下 Enter) 来编辑 settings.json 文件.

Files > Preferences > Workspace Settings (或者按下 kb(workbench.action.showCommands), 输入 worksp 然后按下 Enter) 来编辑工作空间的 settings.json 文件.

你会看到VS Code 默认配置在左侧窗口并且你编辑的 settings.json 在右侧。你可以只是从默认设置查看和拷贝设置。

在完成设置编辑之后,输入 kb(workbench.action.files.save) 来保存更改,更改会立即生效。

settings.json

{  "python.pythonPath": "/usr/local/opt/python3/bin/python3.6"}

2. 调试配置文件launch.json

launch.json

{    // 使用 IntelliSense 了解相关属性。     // 悬停以查看现有属性的描述。    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387    "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": "Python: Attach",            "type": "python",            "request": "attach",            "localRoot": "${workspaceRoot}",            "remoteRoot": "${workspaceRoot}",            "port": 3000,            "secret": "my_secret",            "host": "localhost"        },        {            "name": "Python: Terminal (integrated)",            "type": "python",            "request": "launch",            "stopOnEntry": true,            "pythonPath": "${config:python.pythonPath}",            "program": "${file}",            "cwd": "",            "console": "integratedTerminal",            "env": {},            "envFile": "${workspaceRoot}/.env",            "debugOptions": [                "WaitOnAbnormalExit",                "WaitOnNormalExit"            ]        },        {            "name": "Python: Terminal (external)",            "type": "python",            "request": "launch",            "stopOnEntry": true,            "pythonPath": "${config:python.pythonPath}",            "program": "${file}",            "cwd": "",            "console": "externalTerminal",            "env": {},            "envFile": "${workspaceRoot}/.env",            "debugOptions": [                "WaitOnAbnormalExit",                "WaitOnNormalExit"            ]        },        {            "name": "Python: Django",            "type": "python",            "request": "launch",            "stopOnEntry": true,            "pythonPath": "${config:python.pythonPath}",            "program": "${workspaceRoot}/manage.py",            "cwd": "${workspaceRoot}",            "args": [                "runserver",                "--noreload",                "--nothreading"            ],            "env": {},            "envFile": "${workspaceRoot}/.env",            "debugOptions": [                "WaitOnAbnormalExit",                "WaitOnNormalExit",                "RedirectOutput",                "DjangoDebugging"            ]        },        {            "name": "Python: Flask (0.11.x or later)",            "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": "Python: Flask (0.10.x or earlier)",            "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": "Python: 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": "Python: 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": "Python: 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"            ]        }    ]}

3. 任务配置(直接运行配置)tasks.json

tasks.json

{    "version": "0.1.0",    "command": "python3",    "isShellCommand": true,    "args": ["${file}"],    "showOutput": "always"}

转载地址:http://cwhbo.baihongyu.com/

你可能感兴趣的文章
基于Yum安装zabbix3.0
查看>>
Master-work模式
查看>>
RT-Thread--时间管理
查看>>
BUPT 63T 高才生 找最佳基站
查看>>
linux 学习(二)防火墙
查看>>
scala001
查看>>
android - SpannableString或SpannableStringBuilder以及string.xml文件中的整型和string型代替...
查看>>
自己选择的路,跪着走完吧——一个兔纸的话
查看>>
三端稳压器各个参数解释
查看>>
算法(Algorithms)第4版 练习 1.3.14
查看>>
virtual PC 打造IE6、IE7、IE8、IE9等多版本共存原版测试环境
查看>>
js面向对象1
查看>>
内部类
查看>>
高速数论变换(NTT)
查看>>
Springmvc的跳转方式
查看>>
加密原理介绍,代码实现DES、AES、RSA、Base64、MD5
查看>>
LINUX中常用操作命令
查看>>
python 获取进程pid号
查看>>
链表中插入一个节点的三种情况
查看>>
洛谷.4180.[模板]次小生成树Tree(Kruskal LCA 倍增)
查看>>