Bundled Single Executable on Windows

Windows Single Executable

Windows users are used to programs being a single .exe file that can be
doubleclicked to run. We can produce that kind of user experience, targetting
especially users that are less tech-savvy and e.g. have IE11 as their default
browser which can be problematic. An alternative may be us giving them a
download link to our “app” program, which is basically a bundled Chrome that
loads our web application URL on startup.

The following is one of the many ways to get there:
– Use nativefier to create a portable Chrome loading our web app. Ideally you should build on the target platform (Windows 7 or 10 in our case) Command may look like this:

$ nativefier --name=MyProject "https://myproject.com" --maximize --single-instance
  • This gives us a folder with an executable and a whole bunch of other stuff like .dll files, not very convient yet.
  • We can bundle this into a protable single executable for people to download and run.
  • Of the many broken ways to do this on Windows I found this one to work. Assuming package is the directory created by nativefier and main.py a script as below:
    • Download Python 2.7 (on 3.5, pyinstaller on Windows 10 has huge issues bundling builtin dll files)
    • Create a main.py like below:
    # main.py
    import sys, os
    if getattr(sys, 'frozen', False):
        bundle_dir = sys._MEIPASS
        bundle_dir = os.path.dirname(os.path.abspath(__file__))
    exe = os.path.join(bundle_dir, "MyProject.exe")
    • Install pyinstaller and run it against the script:
    $ pip install virtualenv
    $ virtualenv venv
    $ venv\Scripts\activate
    $ pip install pyinstaller
    $ pyinstaller main.py --onefile --add-data="package;."
    • This will produce dist/main.exe which is our single runnable executable. pyinstaller can also be used to add an icon file --icon=app.ico
All bundled up!


  1. This works pretty well. The only problem I have is it launches a console window too. I tried using –windowed but it doesn’t seem to help. Did that happen to you, did you find a solution?

Leave a Reply to Jason Horman Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.