lap*_*uli 6 visual-studio-code
它过去工作得很好,但最近每当我运行代码 (Python) 时,当我将鼠标悬停在活动终端上时,我都会收到消息“Shell 集成无法激活”。活动的 Python 终端不再识别任何命令行命令,如“pip”(参见屏幕截图)
我能做些什么?我尝试了此处描述的几个设置,但似乎没有任何效果。我当前的setting.json 文件如下所示:
{
"python.defaultInterpreterPath": "C:\\Users\\cleme\\AppData\\Local\\Programs\\Python\\Python310\\python.exe",
"terminal.integrated.profiles.windows": {
"PowerShell": {
"path": "C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe",
"source": "PowerShell",
"icon": "terminal-powershell",
}
},
"terminal.integrated.defaultProfile.windows": "PowerShell"
Run Code Online (Sandbox Code Playgroud)
}
我最终删除了C:\Users\AppData\Roaming中的整个 Code 文件夹。
注意:您必须选中“查看隐藏文件”框才能在文件资源管理器中查看这些文件夹。
这解决了它。
其核心肯定是存在一些奇怪的缓存损坏问题。
我在C:\Users<profile>\AppData\Roaming\Code\logs<datetimestamp>\ptyhost.log中找到了这个
[2022-10-17 07:25:50.695] [ptyhost] [warning] Couldn't get layout info, a terminal was probably disconnected Could not find pty on pty host
[2022-10-17 07:25:54.040] [ptyhost] [warning] Shell integration cannot be enabled for executable "C:\Windows\System32\cmd.exe" and args []
[2022-10-17 07:26:57.939] [ptyhost] [warning] Shell integration cannot be enabled for executable "C:\Windows\System32\cmd.exe" and args []
Run Code Online (Sandbox Code Playgroud)
我认为与此有关。
顺便说一句:当出现问题时,我尝试添加几个 PowerShell VSCode IDE 扩展。IIRC 他们是:
我也将 PowerShell 升级到了最新版本 7。
$PSVersionTable从相应的可执行文件中生成以下内容。
| 可执行路径 | 版本 |
|---|---|
| C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe | 5.1.17763.1852 |
| C:\Program Files\PowerShell\7\pwsh.exe | 7.2.6 |
也许那个组合可以冲洗东西
后续说明:虽然它似乎已经解决了一次问题……但不久之后问题又再次出现了。这次我无法将 VS Code 重置为工作环境。
.vscode\settings.json 仅包含以下内容:
{
}
Run Code Online (Sandbox Code Playgroud)
这又成为一次性解决方案。我最终回到了:
Shell 激活无法为 cmd.exe激活
我将其作为新票发布在这里
| 归档时间: |
|
| 查看次数: |
12886 次 |
| 最近记录: |