anaconda里已经安装好Pytorch,pycharm里正常跑代码,但VS Code显示No module named ‘torch‘

先上个图描述下问题

anaconda里已经安装好Pytorch,pycharm里正常跑代码,但VS Code显示No module named ‘torch‘_第1张图片

环境变量检查了,没有问题,安装了

anaconda里已经安装好Pytorch,pycharm里正常跑代码,但VS Code显示No module named ‘torch‘_第2张图片

 anaconda里已经安装好Pytorch,pycharm里正常跑代码,但VS Code显示No module named ‘torch‘_第3张图片打开vscode   文件--首选项--设置  搜索setting.json

anaconda里已经安装好Pytorch,pycharm里正常跑代码,但VS Code显示No module named ‘torch‘_第4张图片

 打开之后,注释或者删除掉这一行代码

"python.pythonPath":"D:\\ProgramData\\Anaconda3\\envs\\torch\\python.exe"

然后添加 “code-runner.executorMap”会自动出来下面的代码

"code-runner.executorMap": {
        "javascript": "node",
        "java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
        "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "php": "php",
        "python": "python -u",
        "perl": "perl",
        "perl6": "perl6",
        "ruby": "ruby",
        "go": "go run",
        "lua": "lua",
        "groovy": "groovy",
        "powershell": "powershell -ExecutionPolicy ByPass -File",
        "bat": "cmd /c",
        "shellscript": "bash",
        "fsharp": "fsi",
        "csharp": "scriptcs",
        "vbscript": "cscript //Nologo",
        "typescript": "ts-node",
        "coffeescript": "coffee",
        "scala": "scala",
        "swift": "swift",
        "julia": "julia",
        "crystal": "crystal",
        "ocaml": "ocaml",
        "r": "Rscript",
        "applescript": "osascript",
        "clojure": "lein exec",
        "haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",
        "rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt",
        "racket": "racket",
        "scheme": "csi -script",
        "ahk": "autohotkey",
        "autoit": "autoit3",
        "dart": "dart",
        "pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
        "d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",
        "haskell": "runhaskell",
        "nim": "nim compile --verbosity:0 --hints:off --run",
        "lisp": "sbcl --script",
        "kit": "kitc --run",
        "v": "v run",
        "sass": "sass --style expanded",
        "scss": "scss --style expanded"
    }

然后把第8行的 "python": "python -u"改为"python":"D:\\ProgramData\\Anaconda3\\envs\\torch\\python.exe"

"python":"D:\\ProgramData\\Anaconda3\\envs\\torch\\python.exe"

你可能感兴趣的:(pytorch,pycharm,python)