Executing Python script from command line on Windows 7
I seem to have a problem executing a Python script from terminal Win+ R.
I followed these steps:
-
The shebang line is used before entering my script for all .py files. An example of what I did below for a script called
Primefactorization.py
.#! python3
-
I created a batch file in the same folder with the same name and enter the following code:
@python.exe C:\Python Scripts\Primefactorization.py %*
-
I added path (
C:\Python Scripts
) to the variablePATH
in the environment variables window. -
When I try to invoke a script using the Run command in Windows 7, the shell opens and disappears immediately.
-
Building on a past answer to a similar issue on Stack Overflow, I also added the following code prompting the user for input before exiting. But it doesn't work.
x = input('press enter to close')
Could you please let me know where the problem might be?
source to share