简体   繁体   English

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

[英]Using visual studio code without access to powershell

I installed visual studio code & downloaded python extension, When trying to execute code, I get an error that:我安装了 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)

I am not the admin of this laptop as this is office laptop & don't have access to powershell nor will i get the access due to policy.我不是这台笔记本电脑的管理员,因为这是办公室笔记本电脑并且无权访问 powershell,也不会根据政策获得访问权限。 Please suggest what I can do as a remedial measure — I have used only IDLE before for python. How to run code?请建议我可以做些什么作为补救措施——我之前只使用 IDLE python。如何运行代码?

You can change your VScode Terminal default profile您可以更改您的 VScode 终端默认配置文件

首先选择默认配置文件

Select default profile Select 默认配置文件

在此处输入图像描述

Then change from powershell to cmd然后从 powershell 改为 cmd

You can try to add this in the settings.json file:您可以尝试在 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"
    }
  },

If your cmd was forbidden too, you can try to download the Code Runner Extension to execute the code.如果你的cmd也被禁止,你可以尝试下载Code Runner Extension来执行代码。

I had a problem with my Visual studio code, it didn't let me open the terminal it gave me an error "The terminal process failed to launch: A native exception occurred during launch(File not found: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe)".我的 Visual Studio 代码有问题,它不允许我打开终端,它给了我一个错误“终端进程无法启动:启动期间发生本机异常(找不到文件:C:\Windows\System32\ WindowsPowerShell\v1.0\powershell.exe)”。 I solved it by installing the Code Runner Extension.我通过安装 Code Runner Extension 解决了这个问题。

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

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