0

I have pyinstaller2.0** installed and am using Python 2.7.5 32bit on a Windows7-64bit OS.

I'm trying to create an application with no console. When I use --noconsole and click on my generated .exe it doesn't open.

If I change the console to true by using the --console my application runs just fine but I have a console.

I've been searching solid for a few hours here and google and looking at other tutorials and I am not able to find any other threads of this issue.

This is what I have in my batch file for compiling my EXE

c:\python27_32\python.exe pyinstaller.py --onefile --noconsole c:\python27_32\tutorial5.py

Here is my warning file;

W: no module named posix (conditional import by os)
W: no module named readline (delayed, conditional import by cmd)
W: no module named readline (delayed import by pdb)
W: no module named pwd (delayed, conditional import by posixpath)
W: no module named org (top-level import by pickle)
W: no module named posix (delayed, conditional import by __main__)
W: no module named posix (delayed, conditional import by iu)
W: no module named Crypt (delayed, conditional import by __main__)
W: no module named fcntl (conditional import by subprocess)
W: no module named AES (delayed, conditional import by __main__)
W: no module named org (top-level import by copy)
W: no module named _emx_link (conditional import by os)
W: no module named fcntl (top-level import by tempfile)
W: no module named AES (delayed, conditional import by archive)
W: __all__ is built strangely at line 0 - collections (c:\python27_32\lib\collections.pyc)
W: delayed  exec statement detected at line 0 - collections (c:\python27_32\lib\collections.pyc)
W: delayed conditional __import__ hack detected at line 0 - unittest.main (c:\python27_32\lib\unittest\main.pyc)
W: __all__ is built strangely at line 0 - dis (c:\python27_32\lib\dis.pyc)
W: delayed  __import__ hack detected at line 0 - encodings (c:\python27_32\lib\encodings\__init__.pyc)
W: delayed  __import__ hack detected at line 0 - optparse (c:\python27_32\lib\optparse.pyc)
W: delayed  __import__ hack detected at line 0 - ctypes (c:\python27_32\lib\ctypes\__init__.pyc)
W: delayed  __import__ hack detected at line 0 - ctypes (c:\python27_32\lib\ctypes\__init__.pyc)
W: delayed conditional __import__ hack detected at line 0 - unittest.loader (c:\python27_32\lib\unittest\loader.pyc)
W: delayed conditional __import__ hack detected at line 0 - unittest.loader (c:\python27_32\lib\unittest\loader.pyc)
W: delayed  __import__ hack detected at line 0 - unittest.loader (c:\python27_32\lib\unittest\loader.pyc)
W: delayed conditional __import__ hack detected at line 0 - doctest (c:\python27_32\lib\doctest.pyc)
W: delayed  exec statement detected at line 0 - doctest (c:\python27_32\lib\doctest.pyc)
W: delayed conditional __import__ hack detected at line 0 - doctest (c:\python27_32\lib\doctest.pyc)
W: delayed  exec statement detected at line 0 - pdb (c:\python27_32\lib\pdb.pyc)
W: delayed conditional eval hack detected at line 0 - pdb (c:\python27_32\lib\pdb.pyc)
W: delayed  eval hack detected at line 0 - pdb (c:\python27_32\lib\pdb.pyc)
W: delayed conditional eval hack detected at line 0 - pdb (c:\python27_32\lib\pdb.pyc)
W: delayed  eval hack detected at line 0 - pdb (c:\python27_32\lib\pdb.pyc)
W: __all__ is built strangely at line 0 - __future__ (c:\python27_32\lib\__future__.pyc)
W: __all__ is built strangely at line 0 - hashlib (c:\python27_32\lib\hashlib.pyc)
W: __all__ is built strangely at line 0 - tokenize (c:\python27_32\lib\tokenize.pyc)
W: __all__ is built strangely at line 0 - tokenize (c:\python27_32\lib\tokenize.pyc)
W: __all__ is built strangely at line 0 - wx (c:\python27_32\lib\site-packages\wx-2.8-msw-unicode\wx\__init__.pyc)
W: __all__ is built strangely at line 0 - wx (c:\python27_32\lib\site-packages\wx-2.8-msw-unicode\wx\__init__.pyc)
W: delayed  exec statement detected at line 0 - bdb (c:\python27_32\lib\bdb.pyc)
W: delayed  eval hack detected at line 0 - bdb (c:\python27_32\lib\bdb.pyc)
W: delayed  eval hack detected at line 0 - bdb (c:\python27_32\lib\bdb.pyc)
W: delayed  __import__ hack detected at line 0 - pickle (c:\python27_32\lib\pickle.pyc)
W: delayed  __import__ hack detected at line 0 - pickle (c:\python27_32\lib\pickle.pyc)
W: delayed conditional exec statement detected at line 0 - iu (C:\pyinstaller\PyInstaller\loader\iu.pyc)
W: delayed conditional exec statement detected at line 0 - iu (C:\pyinstaller\PyInstaller\loader\iu.pyc)
W: delayed  eval hack detected at line 0 - gettext (c:\python27_32\lib\gettext.pyc)
W: delayed conditional eval hack detected at line 0 - warnings (c:\python27_32\lib\warnings.pyc)
W: delayed conditional __import__ hack detected at line 0 - warnings (c:\python27_32\lib\warnings.pyc)

and here is my spec file output;

# -*- mode: python -*-
a = Analysis(['c:\\python27_32\\tutorial5.py'],
             pathex=['C:\\pyinstaller'],
             hiddenimports=[],
             hookspath=None)
pyz = PYZ(a.pure)
exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          name=os.path.join('dist', 'tutorial5.exe'),
          debug=False,
          strip=None,
          upx=True,
          console=True )
app = BUNDLE(exe,
             name=os.path.join('dist', 'tutorial5.exe.app'))

Everything is fine if I have the console, but nothing happens if I want no console..

Is there something obvious that I am missing?

I appreciate the assistance.

Vinster

Jimbo
  • 25,790
  • 15
  • 86
  • 131

1 Answers1

0

If you never open any GUI windows or anything like that, relying on the console for user I/O, and also suppress the console appearing, the program will launch silently (that is, without opening any windows), which may give the appearance of it not running.

To check this, you have several options.

  1. Make a toy app that just stays around for a while (sleep(30) or something). Compile. Run. Open Task Manager and look for it. If it's there, my hypothesis is correct.
  2. Make a toy app that creates a file somewhere known (like your desktop). Compile. Run. If a file appears, my hypothesis is correct.
  3. Make a toy app that displays a dialog box. Compile. Run. If a dialog appears, my hypothesis is correct.

Basically, if you want to not bother with a console, you need

  1. some other way of interacting with the user, usually a GUI; or
  2. a plan for how the program will function without being able to query, or show results to, the user.

tl;dr

You can't just get rid of the console and expect a program to run unchanged. It will run, but without being able to request input or display results. There's no magic that makes a GUI appear for you.

  • I tried it with a different application that I wrote and it's working as intended. --noconsole does just what I expected. Now to figure out why my application that I need this for isn't working? I am using wxWidgets and wxpython.. the libs are in my path so I didn't think that would had caused this... I would had expected a compiling error due to a broken link. – Vinster411 Jun 08 '13 at 10:13
  • @Vinster411 What was that different application? I need more info. – michaelb958--GoFundMonica Jun 08 '13 at 10:15
  • I was testing between GUI applications early on with what I was going to build my GUI/application with. I went through a tutorial I found online creating a basic windows form with a file menu and a close button... very small and simple and it was a side by side... one application used Tkinter tools and the other used wxWidgets. I found using wxWidgets easier than Tkinter so I did a few weeks of work now in wxwidgets. I'm not in font of my Work laptop right now. I have 5 version/iterations of my application as milestone saves. I'll see if I can build and run any of them with the --noconsole... – Vinster411 Jun 08 '13 at 12:47
  • (Sorry for the multiple links post, I ran out of room) I found the tutorial I used: [link](http://sebsauvage.net/python/gui/) I then built up my wxwidgets up from that but added many imports and any of them could be causing the issue... – Vinster411 Jun 08 '13 at 12:49
  • @Vinster411 Well... When you check that stuff, see if a GUI window appears in both console and no-console modes. If it does, something fishy's going on. – michaelb958--GoFundMonica Jun 08 '13 at 12:57
  • How? I thought the Console was there for print debugging, if your done debugging then the console shouldn't be required anymore. – Vinster411 Jun 08 '13 at 21:12
  • @Vinster411 Hang on... It is noted [here (scroll down a little)](http://sebsauvage.net/python/snyppets/index.html#py2exe) that programs that `print` to a nonexistent console will crash spectacularly. That might be a possible cause (a silent crash doesn't *seem* impossible...). Paste that snippet at the start of your program, see if that changes anything. – michaelb958--GoFundMonica Jun 09 '13 at 04:12
  • I know the print instruction will cause havoc so I have commented them all out using '#'. I didn't have that many. as I passed huddles I removed them. but thanks for the link. I'll also try to compile my app using py2exe tomorrow and see how that goes. I went with Pyinstaller as I wanted a single EXE without any support files. Here is a link to my progress if you're interested, a friend has been helping me with some of the bits [progress](http://www.411overkill.com/viewtopic.php?f=101&t=8378) – Vinster411 Jun 09 '13 at 13:44
  • I was able to create the application using Py2exe and was able to create a single file .exe (Which I couldn't before), I had to add the path for my msvcp90.dll [fix I found here](http://stackoverflow.com/questions/323424/py2exe-fails-to-generate-an-executable) and it created my application just fine. my wx.gauge looks like something from Win95/98 though but it worked. I have no dos console coming up. I'd prefer to get this going with Pyinstaller as my wx.gauge appears the way I'd like and the .exe is half the size. puzzling... – Vinster411 Jun 10 '13 at 10:49
  • I was now able to create my application using pyinstaller but this time I removed the --onefile flag and it works with the --noconsole flag... so with my application something in the --onefile flag is causing my issue. – Vinster411 Jun 10 '13 at 11:04