0

I have this very simple script in a file called test.py:

#!/usr/bin/env python

import sys
print(sys.argv)

when I run it with python test.py arg1 arg2 arg3 it outputs:

['test.py', 'arg1', 'arg2', 'arg3']

which is expected! the problem is when I run it with only test.py arg1 arg2 arg3 it seems not to be reading command line args and prints only:

['test.py']

Before attempting to run the script, I changed the .py file association using Anaconda3 prompt to C:\Users\User\Anaconda3\python.exe as mentioned here and I also manually selected python.exe as the default program to open .py files as follows:

Right click on the file > open with > chose another app > navigate to "C:\Users\User\Anaconda3" and select python.exe > check "always use this app to open .py files" and click ok.

I also read somewhere about shebang so I included that first line in the code but still can't get it to work.

  • This question has previously been answered. https://stackoverflow.com/questions/1934675/how-to-execute-python-scripts-in-windows – Dan Nagle Oct 23 '21 at 11:26

0 Answers0