无法从vscode执行Powershell,因为它以某种方式在Python调试模式下运行

2024-10-01 19:27:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试从vscode运行powershell脚本(按F5执行),但失败了,因为终端将python路径和python调试launcer与powershell路径连接在一起。我如何求解,以便在运行Python脚本时采用Python路径,在运行powershell时自动运行powershell

从vscode运行(F5)powershell脚本时,终端将解释以下路径:

PS C:\Users\luuk\Desktop\Scripts\Archive\Archive>  & 'C:\Users\luuk\AppData\Local\Programs\Python\Python38\python.exe' 'c:\Users\luuk\.vscode\extensions\ms-python.python-2020.11.371526539\pythonFiles\lib\python\debugpy\launcher' '60329' '--' 'c:\Users\luuk\Desktop\Scripts\Archive\Archive\Powershell\StreamingSQLToPBI.ps1'

我需要更改什么才能使vscode自动检测到Powershell路径


Tags: 路径脚本终端scriptsf5vscodeusersappdata
1条回答
网友
1楼 · 发布于 2024-10-01 19:27:44

解决方案:要在VSCode中执行PowerShell脚本,除了安装扩展“PowerShell”,我们还需要打开终端“PowerShell Integrated Console”:(F1PowerShell: Restart Current Session),然后选择代码,然后单击F8在此终端中执行代码

enter image description here

产生这些路径的原因是,在VSCode中,当我们单击F5调试文件时,默认情况下,VSCode在“Python Debug Console”中执行。它将指定终端使用的Python解释器和使用的Python扩展(Python扩展提供Python调试功能),以及要执行的脚本的路径

相关问题 更多 >

    热门问题