Celeb Glow
general | March 13, 2026

Issue opening and running Python in PowerShell

I am new to python programming (already know C) and am following Zed Shaw's book Learn Python the Hard Way. For that, I need to use Python on PowerShell. When I type python in CMD, Python opens up alright and I can use all the commands normally. When I type python in PowerShell, a pop-up window appears, asking me how I want to open the file.

Attached an image here

Why does this happen?

It also happens in VSCode where there are two options to run a Python program. One is labeled as just Run and the other as Run Python file in Terminal. When I click on Run, the same pop-up window appears.

4

1 Answer

You have a file named python located at C:\Users\Admin, and it isn't an executable file(.exe), the file isn't what you are looking for and it can be opened by the programs shown in the dialog, I infer from the programs the extension is either .xml or .pdf, though it is more likely to be .xml.

You can run python in cmd without typing its full path but can't do so in PowerShell is because PowerShell doesn't find the path of the .exe, you likely installed Python to C:\Program Files\Python39, and the folder is added to system path variable and NOT user path, then you must have run cmd as admin so it has access to system path and finds python.exe.

However from the folder path the shell is currently at, you likely haven't started PowerShell as admin, so it doesn't have access to system path and can not find python.exe.

The solution: run powershell as admin.

Also, don't use the default PowerShell, you are missing a lot if you don't use PowerShell 7.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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