本文以python3.7 为例

一 下载python3

url : https://www.python.org/downloads/windows/

提示: 安装过程中。记得勾选  添加环境变量

二 、 vscode 安装所需插件

1  插件名称: python   , 插件功能:  这个是vscode提供的python 官方插件,提供了python代码的调试,自动补全,代码格式化等功能

2 插件名称: vscode-icons , 插件功能: 这个也是vscode官方提供的插件,作用是给vscode编辑的文件增加图标。

3 插件名称:Path Intellisense  ,  插件功能:这个插件的作用是当代码中读入文件名或者文件路径时,提供文件名或者文件路径的自动补全

4 插件名称:Guides , 插件功能: 这个插件的作用是增加 .py  中的指示线,用这个插件能让代码的层次结构更加清晰。

5 插件名称: Bracket Pair Colorizer , 插件功能: 这个插件的作用是给代码中的括号增加颜色,同一对括号是相同的颜色,尤其是在括号中还包着括号的时候,看起来更加的清晰。

6 插件名称: topper , 插件功能:  这个插件的作用是在.py文件的开头添加一些说明header

三 、 配置

1 创建python文件夹

vscode 是基于文件夹的编辑器,我们可以首先建立一个文件夹叫做python,作为我们的Python编程工作空间,只要一次配置好了这个工作空间,以后这个工作空间的配置就会对它之下的所有的.py 文件都起作用。

打开vscode,点击左上角文件 —> 打开文件夹,然后打开刚刚建立的PYTHON 文件夹。新建一个 hello.py 文件

2 配置 launch.json 文件

点击菜单栏调试 —> 打开配置,就会弹出一个选择框,我们在这里要选择Python,然后就打开了launch.json 文件:

我们看到的launch.json 文件中的内容如上图所示。同时我们还发现,在python工作区PYTHON下面还多了一个文件夹.vscode, 而且launch.json 就在这个文件夹中。 
launch.json 文件的配置如下:  这是我配置的全部内容。可以参考一下

{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python3",
"type": "python",
"request": "launch",
"stopOnEntry": false,
"pythonPath": "C:/Users/Administrator/AppData/Local/Programs/Python/Python37", //python3的安装路径
"program": "${file}",
"cwd": "${workspaceFolder}",
"env": {},
"envFile": "${workspaceFolder}/.env",
"debugOptions": [
"RedirectOutput"
]
},
{
"name": "Python: Attach",
"type": "python",
"request": "attach",
"localRoot": "${workspaceFolder}",
"remoteRoot": "${workspaceFolder}",
"port": 3000,
"secret": "my_secret",
"host": "localhost"
},
{
"name": "Python: Terminal (integrated)",
"type": "python",
"request": "launch",
"stopOnEntry": false,
"pythonPath": "C:/Users/Administrator/AppData/Local/Programs/Python/Python37",
"program": "${file}",
"cwd": "",
"console": "integratedTerminal",
"env": {},
"envFile": "${workspaceFolder}/.env",
"debugOptions": []
},
{
"name": "Python: Terminal (external)",
"type": "python",
"request": "launch",
"stopOnEntry": false,
"pythonPath": "C:/Users/Administrator/AppData/Local/Programs/Python/Python37",
"program": "${file}",
"cwd": "",
"console": "externalTerminal",
"env": {},
"envFile": "${workspaceFolder}/.env",
"debugOptions": []
},
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "C:/Users/Administrator/AppData/Local/Programs/Python/Python37",
"program": "${workspaceFolder}/manage.py",
"cwd": "${workspaceFolder}",
"args": [
"runserver",
"--noreload",
"--nothreading"
],
"env": {},
"envFile": "${workspaceFolder}/.env",
"debugOptions": [
"RedirectOutput",
"Django"
]
},
{
"name": "Python: Flask (0.11.x or later)",
"type": "python",
"request": "launch",
"module": "flask",
"env": {
"FLASK_APP": "app.py"
},
"args": [
"run",
"--no-debugger",
"--no-reload"
]
},
{
"name": "Python: Module",
"type": "python",
"request": "launch",
"module": "module.name"
},
{
"name": "Python: Pyramid",
"type": "python",
"request": "launch",
"args": [
"${workspaceFolder}/development.ini"
],
"debugOptions": [
"RedirectOutput",
"Pyramid"
]
},
{
"name": "Python: Watson",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/console.py",
"args": [
"dev",
"runserver",
"--noreload=True"
]
},
{
"name": "Python: All debug Options",
"type": "python",
"request": "launch",
"pythonPath": "${config:python.pythonPath}",
"program": "${file}",
"module": "module.name",
"env": {
"VAR1": "",
"VAR2": ""
},
"envFile": "${workspaceFolder}/.env",
"args": [
"arg1",
"arg2"
],
"debugOptions": [
"RedirectOutput"
]
}
]
}

3 配置 tasks.json 文件

点击菜单栏  终端 —> 配置任务,就会弹出一个选择框,我们在这里要选择使用模板创建tasks.json文件,然后又弹出一个选择框,这里选择Others,就打开了tasks.json 文件:

配置修改如下:

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "python3",
"type": "shell",
"command": "C:/Users/Administrator/AppData/Local/Programs/Python/Python37",
"args": [
"${file}"
]
}
]
}

4 用户设置:

点击菜单栏文件 —> 首选项—> 设置,然后打开用户设置

在扩展里找到 python 打开,在 settings.json 编辑。

{
"window.zoomLevel": 1,
"files.autoSave": "afterDelay",
"explorer.confirmDragAndDrop": false,"editor.renderIndentGuides": false,
"git.ignoreLegacyWarning": true,
"workbench.iconTheme": "vscode-icons", //启用vscode图标
"python.pythonPath": "/usr/bin/python3", // python3路径
"editor.lineHeight": 26, // 编辑器中的行高
"editor.fontSize": 18, // 编辑器中的字体
"editor.wordWrap": "on",
"editor.formatOnSave": true, //编辑器自动保存
"python.linting.flake8Enabled": true,
"python.linting.enabled": false,
//启用flake8,首先需要pip3 install falke8
"python.formatting.provider": "yapf", ///启用yapf,首先需要pip3 install yapf
"path-intellisense.autoSlashAfterDirectory": true,
"path-intellisense.extensionOnImport": true,
"workbench.colorTheme": "Monokai", // 配色方案
"python.linting.pylintArgs": [
"--load-plugins",
"pylint_django",
"--disable-msg=C0111"
], // 忽略的警告信息
// 下面是topper的插入header配置
"topper.customTemplateParameters": [
{
"personalProfile": {
"author": "你的名字",
"website": "bulbasaur.github.bitbucket.yababbdadado.com",
"copyright": "None \n None",
"license": "None",
"email": "你的邮箱"
}
},
{
"officeProfile": {
"author": "John Doe",
"department": "Product Development",
"email": "john.doe@doejohn.com"
}
}
],
"topper.headerTemplates": [
{
"defaultCStyled": {
"headerBegin": "/**",
"headerPrefix": "*",
"headerEnd": "*/",
"template": [
"${headerBegin}",
"${headerPrefix} ${fileName}",
"${headerPrefix} @author ${author}",
"${headerPrefix} @description ${description}",
"${headerPrefix} @created ${createdDate}",
"${headerPrefix} @copyright ${copyright}",
"${headerPrefix} @last-modified ${lastModifiedDate}",
"${headerEnd}"
]
}
},
{
"python": {
"headerBegin": "# -*- coding: utf-8 -*-",
"headerPrefix": "#",
"headerEnd": "#",
"template": [
"${headerBegin}",
"${headerPrefix} ${fileName}",
"${headerPrefix} @author ${author}",
"${headerPrefix} @description ${description}",
"${headerPrefix} @created ${createdDate}",
"${headerPrefix} @last-modified ${lastModifiedDate}",
"${headerEnd}"
]
}
}
],
"editor.fontFamily": "monospace",
"terminal.integrated.fontFamily": "monospace",
"editor.fontWeight": "",
}

四 、 其他

1 需要更新一下pip

cmd 下 执行命令:

python -m pip install --upgrade pip

2 安装 flake 8

cmd 下 执行命令:

pip install flake8

3 查看python 安装路径

>>> import sys
>>> sys.path
['', 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python37\\pyth
on37.zip', 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python37
\\DLLs', 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python37\\
lib', 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python37', 'C
:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-p
ackages']

最终结果: C:\Users\Administrator\AppData\Local\Programs\Python\Python37

配置到此结束,可以愉快玩耍了

快速调试。可以参看这篇文章: https://www.cnblogs.com/richerdyoung/p/12001508.html

【python3】window下 vscode 配置 python3开发环境的更多相关文章

  1. 2016年最新mac下vscode配置golang开发环境支持debug

    网上目前还找不到完整的mac下golang环境配置支持,本人配置成功,现在整理分享出来. mac最好装下xcode,好像有依赖关系安装Homebrew打开终端窗口, 粘贴脚本执行/usr/bin/ru ...

  2. VSCode配置JAVA开发环境

    VSCode配置JAVA开发环境 1:给机器安装JDK.MAVEN 下载JDK 下载路径:https://www.oracle.com/technetwork/java/javase/download ...

  3. Ubuntu Linux下如何配置Android开发环境

    下载和安装Win7系统Android开发环境中讲了怎样在Win7系统中安装Android开发环境,那么怎样在Linux系统中配置Android开发环境呢?本篇文章就将演示如何使用Eclipse.And ...

  4. Vscode配置springboot开发环境变量

    先安装必要的插件 然后在左下角setting 打开setting 配置setting.json文件 ,主要是配置了用户设置 这里面主要配置jdk环境和maven,建议下载vscode推荐的openjd ...

  5. python_在windows下安装配置python开发环境及Ulipad开发工具

    最近开始学习Python,在网上寻找一下比较好的IDE.因为以前用C#做开发的,用Visual Studio作为IDE,鉴于用惯了VS这么强大的IDE,所以对IDE有一定的依赖性. Python的ID ...

  6. 在windows下安装配置python开发环境及Ulipad开发工具(转)

    最近开始学习Python,在网上寻找一下比较好的IDE.因为以前用C#做开发的,用Visual Studio作为IDE,鉴于用惯了VS这么强大的IDE,所以对IDE有一定的依赖性. Python的ID ...

  7. vscode 配置 golang开发环境

    如果你使用golang,那么强烈建议你采用vscode作为IDE. 1. 首先在vscode 当中安装go插件,如上图 2. 配置 %AppData%\Code\User\settings.json ...

  8. vscode配置golang开发环境手把手描述篇

    1.下载安装Golang https://golang.google.cn/dl/ 一路下一步即可 2.下载安装Vscode https://visualstudio.microsoft.com/zh ...

  9. Fedora Linux 下安装配置C开发环境Code::Blocks

    一.提前的话要说C语言和Linux的关系大家应该都不会陌生,Linux系统内核就是用C语言开发的,所以所有的Linux系统下面 都会有C的编译调试工具,不过这些工具都是命令式的,正式开发的话会很不方便 ...

随机推荐

  1. JsonObject和Gson详解

    参考文件:http://www.cnblogs.com/xwdreamer/archive/2011/12/16/2296904.html一.JsonObject 1.JAR包简介 要使程序可以运行必 ...

  2. Web打印控件Lodop实现证件套打

    第一次接触Lodop大概是在两年前了,那时候研究Lodop主要是为了验证它能不能实现打印时在不修改内容的前提下调整样式,结果是ok的,如今又一次接触它,是因为工作中需要使用它了,于是再一次碰面 Lod ...

  3. 【CentOS】安装部署jenkins从git获取代码[转]

    持续集成①安装部署jenkins从git获取代码 一:持续集成的概念: 1.1:总体的概括 持续集成Continuous Integration 持续交付Continuous Delivery 持续部 ...

  4. css 边框使用

    https://www.cnblogs.com/luka/p/5677241.html 1. 应用边框样式 先从控制边框样式的属性开始.简单边框有三个关键属性:border-width.border- ...

  5. Thinkphp5笔记二:创建模块

    系统:window 7 64位 Thinkphp版本:5.0.5 环境:wampserver集成 我的项目是部署在本地www/thinkphp  目录下.在做之前,先要考虑清楚,你需要几个模块来完成你 ...

  6. MSM--Memcached_Session_Manager介绍及使用

    MSM--Memcached_Session_Manager介绍及使用 http://www.iteye.com/topic/1125301 我们都知道对于一些大型的web2.0的网站,在正式部署时一 ...

  7. vue实现文章内容过长点击阅读全文功能

    直接上代码: html: <div class="bodyFont clearfloat" id="bodyFont" ref="bodyFon ...

  8. idea中mybatis generator自动生成代码配置 数据库是sqlserver

    好长时间没有写博客了,最近公司要用java语言,开始学习java,属于初学者,今天主要记录一下mybatis generator自动生成代码,首先在如下图的目录中新建两个文件,如下图 generato ...

  9. tomcat 的 server.xml配置文件

    tomcat的配置文件在其安装后生成的conf目录下,其中主配置文件便是conf下的server.xml文件. server.xml文件由server->service->engine-& ...

  10. 九度 1557:和谐答案 (LIS 变形)

    题目描述: 在初试即将开始的最后一段日子里,laxtc重点练习了英语阅读的第二部分,他发现了一个有意思的情况.这部分的试题最终的答案总是如下形式的:1.A;2.C;3.D;4.E;5.F.即共有六个空 ...