本文以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. (转)YUV420、YUV422、RGB24转换

    //平面YUV422转平面RGB24static void YUV422p_to_RGB24(unsigned char *yuv422[3], unsigned char *rgb24, int w ...

  2. CI框架 -- 核心文件 之 Lang.php(加载语言包)

    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class CI_Lang { var $l ...

  3. Java EE的十三个技术规范

    Java 是一种非常棒的语言,健壮,跨平台运行,屏蔽了具体的平台环境的要求,也就是说只要支持java 虚拟机,就可以运行java程序. 下面,我们一起学习一下J2EE的十三种技术规范. 一.JDBC: ...

  4. docker默认ip查询

    查询docker ip地址 docker-machine ip default

  5. phd文献阅读日志-博一下学期

    博一下学期: 1.week1,2018.2.26 2006-Extreme learning machine: theory and applications 期刊来源:Huang G B, Zhu ...

  6. cocos2d - Changing the image of a CCSprite

    CCTexture2D* tex = [[CCTextureCache sharedTextureCache] addImage:@"new_image_name"]; [spri ...

  7. lua:值得看的博客资源 ...

    凯奥斯 :https://blog.csdn.net/ecidevilin/article/category/6454847 https://blog.csdn.net/qinyuanpei/arti ...

  8. Python 面向对象详解

    Python从设计之初就已经是一门面向对象的语言,正因为如此,在Python中创建一个类和对象是很容易的.本章节我们将详细介绍Python的面向对象编程. 如果你以前没有接触过面向对象的编程语言,那你 ...

  9. A标签添加JS事件,不跳转不刷新办法

    <a href="javascript:;" id="submit-btn" class="submit-btn" title=&qu ...

  10. Unity 协程使用指南

    0x00 前言 在使用Unity的过程中,对协程仅仅知道怎样使用,但并不知道协程的内部机理,对于自己不清楚的部分就像一块大石压力心里.让自己感觉到担忧和不适. 这篇文章一探到底,彻底揭开协程的面纱,让 ...