5

I have a small app that I'm trying to build against windows machines. The program creates an OpenVPN connection. If I build the program and run it it first opens a console as the program output. If I pass the -w parameter to pyinstaller to not build it with a console attached the program fails to run at all. It opens allright but the vpn connection is never created.

With the console everything works perfect.

I also have a basic logging for the application in place to see where my code might stop and nothing gets written. With console on my program spits out all kinds of logs.

I just don't know why my program could be performing perfectly with a console but doing nothing without one. Any ideas?

Romeo Mihalcea
  • 9,714
  • 12
  • 50
  • 102

2 Answers2

4

Gonna answer this myself. Make sure you don't print anything and also you redirect all stdout to a logger, file or whatever else instead of the console.

Romeo Mihalcea
  • 9,714
  • 12
  • 50
  • 102
4

I was having a similar problem, but couldn't find any print/stdout statements going to console. I was using subprocess.Popen and redirecting stdout=subprocess.PIPE. I subsequently added stderr=subprocess.STDOUT and stdin=subprocess.PIPE and my program worked. This page (Python subprocess.call() fails when using pythonw.exe) on subprocess failures helped me get it working.

Community
  • 1
  • 1
Ryan
  • 113
  • 1
  • 6