If you want to use PowerShell to execute Python scripts, you need to have Python installed or you will receive the error below:
Head over to the Microsoft store and download Python. I opted for Python 3.7 but there are newer versions out:
After the install was done, I opened up notepad and created a simple file called PowerShellCheck and saved it with a .py extension in the directory where I have Python 3.7 installed. Here is the line of code:
- print(“Running a Python Script from PowerShell”)
In the same elevated PowerShell window, I executed the script using this command line:
- python PowerShellCheck.py
You should see an output as per the below:
As you can see, it executed perfectly and printed the line I had in the script.
Hope it helps.