当前位置:网站首页>Pytorch has been installed in anaconda, and pycharm normally runs code, but vs code displays no module named 'torch‘

Pytorch has been installed in anaconda, and pycharm normally runs code, but vs code displays no module named 'torch‘

2022-07-05 07:12:00 Weft collar network

First, describe the problem in the previous figure

Environment variables checked , No problem , Installed

  open vscode    file -- Preferences -- Set up   Search for setting.json

  After the open , Comment or delete this line of code

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

Then add  “code-runner.executorMap” The following code will come out automatically

"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"
    }

And then put the 8 Yes  "python": "python -u" Change it to "python":"D:\\ProgramData\\Anaconda3\\envs\\torch\\python.exe"

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

原网站

版权声明
本文为[Weft collar network]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140559586714.html