ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

VSCode配置python环境

2021-07-03 11:00:06  阅读:190  来源: 互联网

标签:false launch VSCode 配置 python json editor vscode


目录
setting.json·是设置语言环境,launch.json是设置执行环境来执行代码,tasks.json是用来设置指令编译代码

1 setting.json

配置python解释器,在vscode界面内按下ctrl+shift+p键,输入python,选择python解释器(python属于解释语言,不需要编译成二进制中间语言,它是依赖解释器,解释一行运行一行)
在这里插入图片描述
然后选择python解释器路径,点击确定后,就会在当前选中的文件夹内生成一个.vscode文件夹且内有一个setting.json文件
在这里插入图片描述
这只是生成一个setting.json模板,可以按照自己需求添加,如下

{
    "python.pythonPath": "D:\\Anaconda3\\envs\\python3",
    "workbench.colorTheme": "Monokai",
    "window.zoomLevel": 0,
    "explorer.confirmDelete": false,
    "editor.accessibilitySupport": "off",
    "editor.formatOnPaste": true,
    "editor.formatOnSave": false,
    "editor.formatOnType": false,
    "editor.showFoldingControls": "mouseover",
    // 控制编辑器是否显示缩进参考线。
    "editor.renderIndentGuides": true,
    "editor.multiCursorModifier": "ctrlCmd",
    # 将原来的cmd.exe 替换为bash.exe  因为更喜欢bash.exe的操作
    "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
    "terminal.integrated.rendererType": "dom",
    "workbench.activityBar.visible": true,
    "python.jediEnabled": false
}

2 launch.json

vscode页面点击运行和调试窗口,点击创建launch.json
在这里插入图片描述
就会自动创建一个launch.json文件

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: 当前文件",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal"
        }
    ]
}

此时也是在.vscode文件夹下生成的
在这里插入图片描述

或者再次模板上添加

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python",
            "type": "python",
            "request": "launch",
            "stopOnEntry": false,
            "program": "${file}",
            "cwd": "${workspaceRoot}",
            "env": {},
            "envFile": "${workspaceRoot}/.env",
            "debugOptions": [
                "WaitOnAbnormalExit",
                "WaitOnNormalExit",
                "RedirectOutput"
            ]
        }
    ]
}

3 task.json

vscode面板内选中 终端—>配置任务...->选择 使用模板创建 tasks.json 文件
在这里插入图片描述
选择Other
在这里插入图片描述
tasks.json文件生成完毕
在这里插入图片描述

标签:false,launch,VSCode,配置,python,json,editor,vscode
来源: https://www.cnblogs.com/jingzh/p/14965811.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有