繁体   English   中英

在不访问 powershell 的情况下使用 visual studio 代码

[英]Using visual studio code without access to powershell

我安装了 visual studio 代码并下载了 python 扩展,当我尝试执行代码时,我得到一个错误:

The terminal process failed to launch: A native exception occurred during launch 
   (File not found: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe)

我不是这台笔记本电脑的管理员,因为这是办公室笔记本电脑并且无权访问 powershell,也不会根据政策获得访问权限。 请建议我可以做些什么作为补救措施——我之前只使用 IDLE python。如何运行代码?

您可以更改您的 VScode 终端默认配置文件

首先选择默认配置文件

Select 默认配置文件

在此处输入图像描述

然后从 powershell 改为 cmd

您可以尝试在 settings.json 文件中添加:

  "terminal.integrated.defaultProfile.windows": "Command Prompt",
  "terminal.integrated.profiles.windows": {
    "PowerShell": {
      "source": "PowerShell",
      "icon": "terminal-powershell",
      "path": ["C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"]
    },
    "Command Prompt": {
      "path": [
        "${env:windir}\\Sysnative\\cmd.exe",
        "${env:windir}\\System32\\cmd.exe"
      ],
      "args": [],
      "icon": "terminal-cmd"
    }
  },

如果你的cmd也被禁止,你可以尝试下载Code Runner Extension来执行代码。

我的 Visual Studio 代码有问题,它不允许我打开终端,它给了我一个错误“终端进程无法启动:启动期间发生本机异常(找不到文件:C:\Windows\System32\ WindowsPowerShell\v1.0\powershell.exe)”。 我通过安装 Code Runner Extension 解决了这个问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM