1

I made a program with python and I want to turn it into an .exe file. I typed that command from the command prompt (cmd):

pyinstaller --onefile --noconsole script.py

I used Tkinter in my script. When I run the .exe file, a window didn't appear. How can I solve it?

@Charitoo I'm using Windows 7 32bit, Python 2.7.3

ballade4op52
  • 2,142
  • 5
  • 27
  • 42
python_pardus
  • 310
  • 2
  • 5
  • 14
  • source code is missing? – rahul tyagi Jul 25 '15 at 21:17
  • @rahul tyagi It's not clear that where is the error in the program. So, I don't want to publish my source codes and when I remove one of these commands (--onefile and --noconsole), the problem solves. But I want to use both of them. – python_pardus Jul 25 '15 at 21:22
  • @python_pardus Your program is probably throwing an error, but you can't see it. Use a `try`-`except` and log the traceback to see what's happening when using those options. – cdonts Jul 25 '15 at 21:49
  • @cdonts No, It hasn't throwen any error. – python_pardus Jul 26 '15 at 10:37
  • @cdonts Sorry, It has throwen error. But my program couldn't write error to file. It could create file but It couldn't write anything. I couldn't understand reason of this issue(It couldn't write). – python_pardus Jul 27 '15 at 11:23
  • @python_pardus How are you logging errors? – cdonts Jul 27 '15 at 19:17

2 Answers2

1

Use this command.

pyinstaller --onefile --windowed script.py

That should solve the problem.

Charitoo
  • 1,814
  • 17
  • 21
1

I've solved my problem, because I could understand the reason for it. I was using this code in my Python script:

from subprocess import check_output
check_output("chcp 1254", shell=True)

I deleted these codes and my problem was solved.

These codes were the reason for the problem, because I was creating an exe file which doesn't have a console screen, but I was using a command which tries to access the command line. Therefore, my program was closing. Thanks to everybody.

ballade4op52
  • 2,142
  • 5
  • 27
  • 42
python_pardus
  • 310
  • 2
  • 5
  • 14