Running Python in PowerShell? Running Python in PowerShell? python python

Running Python in PowerShell?


Since, you are able to run Python in PowerShell. You can just do python <scriptName>.py to run the script. So, for a script named test.py containing

name = raw_input("Enter your name: ")print "Hello, " + name

The PowerShell session would be

PS C:\Python27> python test.pyEnter your name: Monty PythonHello, Monty PythonPS C:\Python27>


As far as I have understood your question, you have listed two issues.

PROBLEM 1:

You are not able to execute the Python scripts by double clicking the Python file in Windows.

REASON:

The script runs too fast to be seen by the human eye.

SOLUTION:

Add input() in the bottom of your script and then try executing it with double click. Now the cmd will be open until you close it.

EXAMPLE:

print("Hello World")input()

PROBLEM 2:

./ issue

SOLUTION:

Use Tab to autocomplete the filenames rather than manually typing the filename with ./ autocomplete automatically fills all this for you.

USAGE:

CD into the directory in which .py files are present and then assume the filename is test.py then type python te and then press Tab, it will be automatically converted to python ./test.py.


Go to Control PanelSystem and SecuritySystem, and then click Advanced system settings on the left hand side menu.

On the Advanced tab, click Environment Variables.

Under 'User variables' append the PATH variable with path to your Python install directory:

C:\Python27;