2

I have a python program that I am converting to a .exe file. I have compiled with Pyinstaller and all is working fine. I now want to get rid of the console window as I have a pyqt user interface. I have tried:

pyinstaller --onefile --windowed --icon=favicon.ico main.py

Its compiling fine and running however when chromedriver is activated it doesnt show up. It works fine when i do not use --windowed or --noconsole.

Anyone had this problem before?

Thanks Jamie

Jamie Smith
  • 95
  • 2
  • 3
  • 9

4 Answers4

6

I know that this question has been since 2016, but I would like to share my knowledge.

Try to put --noconsole before --onefile.

So, the command will be:

pyinstaller --noconsole --onefile --windowed --icon=favicon.ico main.py
2

In Python 2.7 use subprocess like this:

DEVNULL = open(os.devnull,"wb")
output = subprocess.check_output(command, shell=True,stderr=DEVNULL,stdin=DEVNULL)

In Python 3 use subprocess like this:

DEVNULL = subprocess.DEVNULL
output=subprocess.check_output(command,shell=True, stderr = DEVNULL , stdin = DEVNULL )

Hopefully it will solve your problem.

H S Umer farooq
  • 871
  • 8
  • 14
1

add --noconsole flag to your script call and remove --windowed, I tested this and it worked for me.

this would be :

pyinstaller --noconsole --icon=favicon.ico main.py
syedelec
  • 1,225
  • 2
  • 18
  • 30
  • 1
    I tried --noconsole and it still was failing to bring up selenium. I will try again without the --onefile and see if that works. Cheers – Jamie Smith Nov 17 '16 at 18:04
  • can you describe your environment, python version, os etc.. ? – syedelec Nov 17 '16 at 18:23
  • Hi, using python 3.4 on windows. I believe its the --onefile that is creating the program. Tried --windowed and --noconsole without the --onefile and that seems to work. Only problem is that when chromedriver launches now it includes a console popup. not sure if there is anyway to get rid of that – Jamie Smith Nov 17 '16 at 18:36
  • There is a workaround to hide chromedriver console that implies modifying the driver itself in Python, I did not try it myself, you can look at it in this post (2nd answer): [link](http://stackoverflow.com/questions/33983860/hide-chromedriver-console-in-python) – syedelec Nov 17 '16 at 18:53
1

Change the extension of your main (GUI) file. From: *.py to *.pyw (Python officially supported).

Then: pyinstaller --onefile --noconsole main.pyw

This worked for me.

Dan A.S.
  • 591
  • 6
  • 22