I'm on Windows 10 using Python 3.6, and I notice that whenever I double click on a Python file (for example, from File Explorer): enter image description here It runs inside a command prompt window! I would prefer if it were to open up inside a PowerShell window instead. I stumbled across this answer here: Run Python scripts in PowerShell directly But it seems that the .py extension is already added to that environment variable in my case and it still opens up in cmd. So I'm not sure what to do.

Is there any way to change this?

2 Answers 2


No. Windows Command Prompt (cmd.exe) is not launched. Because the Python interpreter is a command-line program, Windows Console Host (conhost.exe) is launched and provides a terminal interface to the Python interpreter.

I guess, by "run in PowerShell", you mean the PS-style blue background. This cannot be easily done unless you open up a PS first and run Python inside it (though it's possible).

You can do this by wrapping the Phthon interpreter up with a batch file:

@echo off
color 1F
python %*

Then edit the registry to run py scripts with mywrapper.bat %1


I think you can do this using subprocess module

import subprocess

This should call PowerShell directly instead of calling command prompt and then passing the command via it to PowerShell

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.