• vs code搭建python和tensorflow环境


    anaconda 安装tensorflow-gpu环境见https://www.cnblogs.com/wintersoft/p/11620267.html

    vscode中设置python虚拟环境
    Ctrl+Shift+P,选择Python:Select Interpreter,选中tensorflow-gpu虚拟环境
    会自动在settings.json文件中生成,如:

    {
      "python.pythonPath": "C:\ProgramData\Anaconda3\envs\tensorflow-gpu\python.exe"
    }

    或手动配置,自己在.vscode文件夹里新建settings.json

    {
      "python.pythonPath": "C:\ProgramData\Anaconda3\envs\tensorflow-gpu\python.exe",
      "python.autoComplete.extraPaths": [
        "C:\ProgramData\Anaconda3\envs\tensorflow-gpu",
        "C:\ProgramData\Anaconda3\envs\tensorflow-gpu\Lib\site-packages"
      ],
      "python.autoComplete.addBrackets": true,
      "python.jediEnabled": true, }

    F5调式特定启动文件,可修改为:

    {
        // 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",
                // "pythonPath": "C:\ProgramData\Anaconda3\envs\tensorflow-gpu\python.exe",
                "pythonPath": "${config:python.pythonPath}",
                // "program": "${file}",
                "program": "${workspaceRoot}\hello.py",
                "console": "integratedTerminal",
                "stopOnEntry": false,
                // "env": {"PYTHONPATH":"${workspaceRoot}"},
                // "envFile": "${workspaceRoot}/.env",
            }
        ]
    }

    VS code python 环境下提示找不到 module报unresolved import "xxx"
    https://github.com/DonJayamanne/pythonVSCode


    进入launch.json文件,configurations节点下加入:
    "env": {"PYTHONPATH":"${workspaceRoot}"},
    "envFile": "${workspaceRoot}/.env",

    进入settings.json文件,加入:
    "python.jediEnabled": true,

    然后重启vs code

    注:"python.jediEnabled": true后,安装pylint后会报:
    No name 'python' in module 'tensorflow'pylint(no-name-in-module)和
    Unable to import 'tensorflow.python.client'pylint(import-error) 之类的错

    推荐插件安装:

    Python

    Visual Studio IntelliCode

    Anaconda Extension Pack

    Settings Sync

    Beautify

    Atuo Rename Tag

    Project Manager

  • 相关阅读:
    0714买卖股票的最佳时机含手续费 Marathon
    0070爬楼梯 Marathon
    0045跳跃游戏II Marathon
    0343整数拆分 Marathon
    0406根据身高重建队列 Marathon
    0096不同的二叉搜索树 Marathon
    0763划分子母区间 Marathon
    0435无重叠区间 Marathon
    0452用最少数量的箭引爆气球 Marathon
    0509斐波那契数 Marathon
  • 原文地址:https://www.cnblogs.com/wintersoft/p/11630197.html
Copyright © 2020-2023  润新知