Vscode coderunner运行环境问题

现象

conda装了各种包,coderunner运行py项目显示环境有问题

解决办法

打开setting文件添加如下信息,输入“code-runner”会自动补全,
修改python对应的环境路径即可

"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": "/Users/abc/opt/anaconda3/envs/tensorflowcpu_env/bin/python",
        "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",
        "less": "cd $dir && lessc $fileName $fileNameWithoutExt.css",
        "code-runner.runInTerminal": false
    },
配置c++11
g++ 改为 g++ -std=c++11
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在 VSCodeCode Runner 插件中配置 C++ 环境,需要完成以下步骤: 1. 安装 Code Runner 插件 在 VSCode 中搜索并安装 Code Runner 插件,安装完成后重新启动 VSCode。 2. 安装 C++ 编译器 在 Windows 中,可以安装 MinGW-w64 或者 Visual Studio 等编译器。在 Mac 上,可以安装 Xcode。在 Linux 上,可以安装 GCC。 3. 配置 Code RunnerVSCode 中打开 Code Runner 插件的设置,可以通过 "File" -> "Preferences" -> "Settings" 或者快捷键 "Ctrl + ," 打开设置页面。在搜索框中输入 "code-runner.executorMap",找到 "Executor Map" 选项,并点击 "Edit in settings.json" 按钮。 在 settings.json 文件中,添加以下代码: ``` "code-runner.executorMap": { "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt" } ``` 这里我们以 g++ 编译器为例,如果你使用的是其他编译器,可以将上面代码中的 "g++" 替换为相应的编译器名字。 4. 运行代码 在 VSCode 中打开一个 C++ 代码文件,按下 "Ctrl + Alt + N" 快捷键,或者点击菜单栏中的 "Run Code" 按钮,即可运行代码。 注意:如果你在 Code Runner 插件的配置中修改了默认的编译器,记得在代码文件中第一行添加相应的编译器指令,例如: ``` // 如果你使用的是 g++ 编译器 // #include <bits/stdc++.h> // using namespace std; // #define compiler "g++ -std=c++11" ``` 这样 Code Runner 插件就可以自动识别你使用的编译器了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值