I'm new to Python (3.10.4). I've been reading Mark Lutz's textbook and I'm only getting comfortable with the environment (Windows 10), and all this time I've been under the impression there's no real difference between running Python programs in cmd or powershell. However, today I followed the suggestion from the textbook and tried launching a Python script file without typing "python" at the start of the command line, and PowerShell returned me an error message saying "[the script file name] could not be identified as a Cmdlet, a function, a scriptfile or a executeable program." At first I thought I was doing something wrong, but then I tried doing the same in cmd, and I got the expected output. So, in cmd this syntax works just fine.
Then I noticed the PowerShell suggestion that was printed out below the error message. It said if I trust the command, I should run it with a different syntax, so not like
filename.py
but like
.\filename.py
I tried doing this, and it launched the file (a tiny black window blinked as if I double clicked the file), but I didn't get the output in the PowerShell window this time either.
So, my question is: what's the difference between cmd and powershell from the Python perspective? Why do they treat Python differently? And as I study Python, should I stick to cmd rather than to PowerShell from now on?