簡體   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