简体   繁体   中英

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. 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.

However, with Windows 11, it is now possible to change the default terminal application. This currently needs a Windows Terminal Preview version.

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 )

You can have this behaviour on double click by changing

HKEY_CLASSES_ROOT\Python.File\Shell\open\command

default value from:

"C:\Windows\py.exe" "%L" % *

to

"C:\Users\USER\AppData\Local\Microsoft\WindowsApps\wt.exe" "python" "%L" % *

(you have to replace "USER" with the username on your windows machine)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM