【问题标题】:how to add Python to windows terminal app?如何将 Python 添加到 Windows 终端应用程序?
【发布时间】:2021-05-15 03:26:36
【问题描述】:

我只想将 Python 添加到 windows 终端应用程序的选项卡选项中。我在 powershell 中使用以下代码提取了 GUID

>>     [OutputType([System.Management.Automation.PSObject])]
>>     [CmdletBinding()]
>>     param (
>>         [Parameter()]
>>         [ValidateNotNullOrEmpty()]
>>         [string]$Name
>>     )
>>
>>     $UninstallKeys = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall", "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
>>     $null = New-PSDrive -Name HKU -PSProvider Registry -Root Registry::HKEY_USERS
>>     $UninstallKeys += Get-ChildItem HKU: -ErrorAction SilentlyContinue | Where-Object { $_.Name -match 'S-\d-\d+-(\d+-){1,14}\d+$' } | ForEach-Object { "HKU:\$($_.PSChildName)\Software\Microsoft\Windows\CurrentVersion\Uninstall" }
>>     if (-not $UninstallKeys) {
>>         Write-Verbose -Message 'No software registry keys found'
>>     } else {
>>         foreach ($UninstallKey in $UninstallKeys) {
>>             if ($PSBoundParameters.ContainsKey('Name')) {
>>                 $WhereBlock = { ($_.PSChildName -match '^{[A-Z0-9]{8}-([A-Z0-9]{4}-){3}[A-Z0-9]{12}}$') -and ($_.GetValue('DisplayName') -like "$Name*") }
>>             } else {
>>                 $WhereBlock = { ($_.PSChildName -match '^{[A-Z0-9]{8}-([A-Z0-9]{4}-){3}[A-Z0-9]{12}}$') -and ($_.GetValue('DisplayName')) }
>>             }
>>             $gciParams = @{
>>                 Path        = $UninstallKey
>>                 ErrorAction = 'SilentlyContinue'
>>             }
>>             $selectProperties = @(
>>                 @{n='GUID'; e={$_.PSChildName}},
>>                 @{n='Name'; e={$_.GetValue('DisplayName')}}
>>             )
>>             Get-ChildItem @gciParams | Where $WhereBlock | Select-Object -Property $selectProperties
>>         }
>>     }
>> }
PS C:\Users\AAKASH GAUTAM> Get-InstalledSoftware -Name 'Python 3.9.0 (64-bit)'

我使用以下代码编辑了 setting.json,但选项菜单中没有出现任何内容。我在这里做错了什么?

      {
      "guid": "{a2a37ca0-8ebd-4d7e-b4b8-e6b1740c2ce0}",
      "commandline" : "C:\\Users\\AAKASH GAUTAM\\AppData\\Local\\Programs\\Python\\Python39\\python.exe",
      "icon" : "C:\\Users\\Aakash Gautam\\AppData\\Local\\Programs\\Python\\Python39\\Lib\\test\\imghdrdata\\python.png",
      "hidden": false,
      "name": "Python",
      "source": "Python.exe",
      "closeOnExit" : true,
      "startingDirectory": "C:\\Users\\Aakash Gautam\\Desktop\\"
      }

【问题讨论】:

    标签: python windows-terminal


    【解决方案1】:
          {
            "guid" : "{a2a37ca0-8ebd-4d7e-b4b8-e6b1740c2ce0}",
            "name" : "Python",
            "commandline" : "py.exe",
            "icon" : "C:/Users/Aakash Gautam/AppData/Local/Programs/Python/Python39/Lib/test/imghdrdata/python.png",
            "startingDirectory": "C:\\Users\\Aakash Gautam\\Desktop\\"
          }
    

    我认为问题在于命令行参数和图标路径中的正斜杠。

    【讨论】:

      猜你喜欢
      • 2012-02-29
      • 2018-06-10
      • 1970-01-01
      • 2022-01-20
      • 1970-01-01
      • 2020-06-15
      • 2019-11-12
      • 1970-01-01
      • 2012-11-20
      相关资源
      最近更新 更多