【问题标题】:vscode "Run Without Debugging" doesn't open Python Debug Consolevscode \"Run without Debugging\" 不打开 Python 调试控制台
【发布时间】:2022-08-05 12:11:08
【问题描述】:

VSCode\'s \"Run without Debugging\" 运行 python 文件(我可以从时间过去看出),但它没有打开任何面板/终端来显示输出。

我已经卸载/重新安装了 Microsoft python 扩展,并在退出/重新打开 VSCode 后,在带有单个 \"test.py\" 文件的全新目录中,在任何工作区之外运行上述实验。

如何让 VSCode 在“不调试运行”时打开“Python 调试控制台”?

    标签: python visual-studio-code


    【解决方案1】:

    您可以在setting.json 中手动设置pythonpath 的内容。

    "python.pythonpPath":"the location of your python.exe" #Note that python.EXE is used here. If you use conda environment, the default configuration may be set to pythonw.exe
    

    【讨论】:

    • 我的解决方案能解决您的问题吗?
    【解决方案2】:

    我找到了另一种可能的解决方案。

    您可以通过添加以下代码在setting.json 中指定shell:

    "terminal.integrated.shell.windows":"C:\\WINDOWS\\system32\\cmd.exe",
    

    当然,这种方法已经过时了,我们也会收到警告(但不会影响其有效性):

    根据update of document,我们可以通过以下方式命名终端并指定默认终端:

        {
      "terminal.integrated.profiles.windows": {
        "My PowerShell": {
          "path": "pwsh.exe",
          "args": [
             "-noexit",
             "-file",
             "${env:APPDATA}\PowerShell\my-init-script.ps1"
          ]
        }
      },
      "terminal.integrated.defaultProfile.windows": "My PowerShell"
    }
    

    【讨论】:

      【解决方案3】:

      在菜单栏的顶部有一个名为“终端”的选项卡单击它,然后点击新终端

      【讨论】:

      • 我还可以从面板中创建新终端。如果我运行命令“Python:在终端中运行文件”,也会出现一个终端窗口。但这并不能解决我的问题:“在不调试的情况下运行”仍然无法打开面板/显示输出。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-07-03
      • 1970-01-01
      • 2017-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多