command line arguments not being passed to generated Windows executable

1,917 views
Skip to first unread message

JB

unread,
Sep 18, 2013, 3:02:38 PM9/18/13
to pyins...@googlegroups.com
I use pyinstaller to compile a python program for both Windows and Linux. I've recently extended my program to accept command line arguments to provide the same functionality as the GUI. However, it seems those command line arguments are ignored on Windows, even though they work just fine on Linux. To be clear, I'm talking about command line arguments being passed to the generated executable. I tested that the command line arguments work on Windows when I run my program directly with python, before I compile with PyInstaller. I'm using the same arguments (--onefile --windowed) on both Windows and Linux to create the .spec file.

Has anyone else experienced this behavior before? Does anybody have and idea why command line arguments would work for Linux and not for Windows?

Thanks.

Hartmut Goebel

unread,
Sep 18, 2013, 5:38:13 PM9/18/13
to pyins...@googlegroups.com
Am 18.09.2013 21:02, schrieb JB:
Has anyone else experienced this behavior before? Does anybody have and idea why command line arguments would work for Linux and not for Windows?

We have a test case for this: interactive/test_argv_emulation.py

Can you please whether this test-case shows the same effect?

--
Schönen Gruß
Hartmut Goebel
Dipl.-Informatiker (univ), CISSP, CSSLP

Goebel Consult
http://www.goebel-consult.de

Monatliche Kolumne: http://www.cissp-gefluester.de/2012-04-compliance-bringt-keine-sicherheit
Blog: http://www.goebel-consult.de/blog/20041011

Goebel Consult ist Mitglied bei http://www.7-it.de/

Naib

unread,
Sep 19, 2013, 7:20:33 AM9/19/13
to pyins...@googlegroups.com
Silly question, but pre-packaged does the commandline work in windows?
I ask because passing argument works for me 

ONE thing that doesn't fully is what is displayed in the terminal in windows for the packaged (some print statements, some exception errors etc..) this is for gui and cli applications.
ie from what I have seen is sys.argv is not interfered with BUT stdout maybe

JB

unread,
Sep 20, 2013, 6:26:05 PM9/20/13
to pyins...@googlegroups.com
Thanks for the responses. After some more testing I realized the problem is indeed that messages to stdout are not being displayed and not that the command line arguments are not recognized. My program is written to have both a GUI and a command line interface. If I use the command line arguments that cause my program to do useful work, it does that, but if I use the argument to print the help statement to screen, I see nothing. I guess it's too much to ask for both for the Windows executable. I expect most of the people who want to use my program as a command-line utility will be on Linux anyway, where this problem doesn't exist. Those that want to use the command line in Windows, still can, they just won't get any useful messages in return.

Thanks again.

Amaury Rodriguez

unread,
Dec 6, 2013, 3:18:20 PM12/6/13
to pyins...@googlegroups.com
Is it possible to have both --windowed and --console modes? I have a dual-interface app and I want the user to be able to use the CLI normally.

Thanks
Reply all
Reply to author
Forward
0 new messages