1

I am using Windows 10 and I wrote a python script to open an external .exe program. The python version is Python 3.6.
I use subprosee.Popen(command, shell = True) to run command. (If I did not inclue the shell=True parameter it won't work properly)
There is a sentence print(sys.argv). When I run command like >python program.py arg1 arg2 in windows command prompt, a python shell will be started and it got shown twice. In Command Prompt is shows:
['program.py' 'arg1' 'arg2']
However, in python shell it shows:
['program.py']
Which means the arguments are not passed into python script properly. How should I solve this? I have searched some hints online and someone mentions the association configuration. I did the following thing:
assoc .py=Python.File ftype Python.File="C:\Anaconda3\python.exe" "%1" %*
but the weird thing is that although I can find Python.File="C:\Anaconda3\python.exe" "%1" %* by ftype | findstr -i python, it shows File type 'Python.File' not found or no open command associated with it. when I type ftype Python.File.
enter image description here I also configure the register info manually. r So what should I do to solve this problem? Your help will be very important to me.

3
  • I expect you might need to logout-login to reload the file association information after manual editing. Commented Nov 16, 2018 at 22:15
  • 2
    I don't understand very well how you run your script when using the python shell. Could you describe it more precisely? Commented Nov 16, 2018 at 22:21
  • ftype and assoc always seemed unreliable to me. What I did is associate .py to the python exe, then find the entry in the registry and add %1 %* (stackoverflow.com/a/38612907/6451573) Commented Nov 16, 2018 at 22:24

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.