VSCode中 Python3环境的设置

以下为:vscode 版本 1.31.1的关于python3运行环境的设置。

vscode下载及python虚拟环境的新建

  1. vscode下载地址
    https://code.visualstudio.com/Download,在这里我选择的是windows64位系统绿色版,下载完成后解压即可。
  2. python3虚拟环境的设置
    打开cmd,运行virtualenv D:\develop\python\vscodeenv,创建关于vscode虚拟环境。

设置vscode下python3环境

  1. 设置vscode语言为中文,设置步骤如下,最后点击下载,待完成后重启既可以。
    VSCode中 Python3环境的设置

  2. 安装python插件,和以上方法类似,搜索python,如下:
    VSCode中 Python3环境的设置

  3. 添加调试设置:新建一个文件夹工作区,再点击菜单栏调试 —> 添加配置,在打开的launch.json文件中,进行以下的设置:

    {
    // 使用 IntelliSense 了解相关属性。
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    “version”: “0.2.0”,
    “configurations”: [
    {
    “name”: “Python3”,
    “type”: “python”,
    “request”: “launch”,
    “stopOnEntry”: false,
    “pythonPath”: “D:\develop\python\vscodeenv\Scripts\python”, //python3的安装路径
    “program”: “file","cwd":"{file}", "cwd": "file","cwd":"{workspaceFolder}”,
    “env”: {},
    “envFile”: “KaTeX parse error: Expected 'EOF', got '}' at position 95: … ] }̲ { …{file}”,
    “cwd”: “”,
    “console”: “integratedTerminal”,
    “env”: {},
    “envFile”: “KaTeX parse error: Expected 'EOF', got '}' at position 57: …tions": [] }̲, { …{file}”,
    “cwd”: “”,
    “console”: “externalTerminal”,
    “env”: {},
    “envFile”: “KaTeX parse error: Expected 'EOF', got '}' at position 57: …tions": [] }̲, { …{workspaceFolder}/manage.py”,
    “cwd”: “workspaceFolder","args":["runserver","noreload","nothreading"],"env":,"envFile":"{workspaceFolder}", "args": [ "runserver", "--noreload", "--nothreading" ], "env": {}, "envFile": "workspaceFolder","args":["runserver","−−noreload","−−nothreading"],"env":,"envFile":"{workspaceFolder}/.env”,
    “debugOptions”: [
    “RedirectOutput”,
    “Django”
    ]
    },
    ]
    }

  4. 修改用户设置:经过以上步骤,还未选择到自己想要的python虚拟环境,需要修改用户设置。

1>.在vscode界面运行:Ctrl + Shift + P ; 输入Open Settings
2>.在弹出的界面中,搜索“pythonPath”,步骤如下:
VSCode中 Python3环境的设置
3>.在settings.json中,设置:“python.pythonPath”: “D:\develop\python\vscodeenv\Scripts\python”
4>.此时运行新建的python,即使用了我们的虚拟环境vscodeenv运行。
VSCode中 Python3环境的设置

个人博客:Loak 正 - 关注人工智能及互联网的个人博客
文章地址:VSCode中 Python3环境的设置

上一篇:3、nacos集群部署


下一篇:[Docker] 学习记录