Python won't load in Powershell although it does in CMD

I get the following message in Powershell in response to “py” or “python”

 python : Python 3.10.7 (tags/v3.10.7:6cc6b13, Sep  5 2022, 14:08:36) [MSC v.1933 64 bit 
 (AMD64)] on win32
 At line:1 char:1
 + python
 + ~~~~~~
 + CategoryInfo          : NotSpecified: (Python 3.10.7 (...MD64)] on win32:String) [], 
+ FullyQualifiedErrorId : NativeCommandError

Type “help”, “copyright”, “credits” or “license” for more information.

Subsequent to which Powershell will not accept any further input, i.e. it apparently crashes.

You’re running PowerShell in ISE (integrated scripting environment). In this environment, stdout and stderr are pipes, for which I/O is fully buffered, and stdin is console input from a console session that has a hidden window and thus no where for you to actually enter text. This environment is not intended for running interactive console applications.

Run PowerShell (i.e. powershell.exe or pwsh.exe) in a normal console session, either a classic conhost.exe window, or an openconsole.exe tab in Terminal. Note that, conceptually, you’ll be running Python from PowerShell, not in it. Python will inherit its console session from the shell, while the shell itself waits in the background. It’s exactly the same when Python is run from the CMD shell, not in it.

1 Like