[英]How to open Python files in the new Windows Terminal?
I'm trying out the Windows Terminal app and I want to start using it instead of CMD. The problem is, I cannot set the File Explorer to open Python files with it by default.我正在试用 Windows 终端应用程序,我想开始使用它而不是 CMD。问题是,我无法将文件资源管理器设置为默认使用它打开 Python 文件。 I tried using the Open button leading to the file path, but I get the following error
我尝试使用通向文件路径的“打开”按钮,但出现以下错误
wt
重量
The file cannot be accessed by the system.系统无法访问该文件。
With Windows 10, there is no way to change the default terminal from Windows Console Host to Windows Terminal.对于 Windows 10,无法将默认终端从 Windows 控制台主机更改为 Windows 终端。
However, with Windows 11, it is now possible to change the default terminal application.但是,在 Windows 11 中,现在可以更改默认终端应用程序。 This currently needs a Windows Terminal Preview version.
这当前需要 Windows Terminal Preview 版本。
You can activate this from either in Windows 11 Settings ( Choose the default terminal app to host the user interface for command-line applications ) or in Windows Terminal Preview ( Settings->Startup->Default Terminal Application )您可以在 Windows 11 设置(选择默认终端应用程序来托管命令行应用程序的用户界面)或 Windows 终端预览(设置->启动->默认终端应用程序)中激活它
You can have this behaviour on double click by changing您可以通过更改双击来获得此行为
HKEY_CLASSES_ROOT\Python.File\Shell\open\command HKEY_CLASSES_ROOT\Python.File\Shell\open\command
default value from:默认值来自:
"C:\Windows\py.exe" "%L" % * "C:\Windows\py.exe" "%L" % *
to到
"C:\Users\USER\AppData\Local\Microsoft\WindowsApps\wt.exe" "python" "%L" % * "C:\Users\USER\AppData\Local\Microsoft\WindowsApps\wt.exe" "python" "%L" % *
(you have to replace "USER" with the username on your windows machine) (你必须用你的 windows 机器上的用户名替换“USER”)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.