Author Archives: admin

Run Python in PowerShell

You can run Python in PowerShell the same way as from the command bar.

Run PowerShell Command as Admin

First, you have to start PowerShell as Admin. To do it, just click the magnifying glass on the Windows Toolbar and enter “powershell”.

Next, right-click the icon and run it as administrator.

Run Python code

Now, when you have the PowerShell window open, you can start the Python interpreter by typing “python”.

Run Python Script

In the previous section, you saw a simple text message that was executed in the python interpreter, using PowerShell.

To leave the Python interpreter, press Ctrl + Z and then Enter.

Navigate to the directory where your script is located and use this command:

It will run the script that is inside the script.py file.

You can also run a script without changing the current dictionary, by specifying an absolute path to a file. You can use both forward-slash (/) and backslash (\).

Run Script with Arguments

When you run Excel scripts, you can pass arguments from the command line. Take a look at this code from the sum.py file:

It takes two numbers from the command line (sys.argv[1] and sys.argv[1]) and sum them returning text and the addition result. sys.argv[0] is the first argument of our entry, which is the name of a script (sum.py).