Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating an Exe with Selenium Module: Py2exe/Pyinstaller

I've looked everywhere. Stackoverflow, various messageboards, the py2exe website, the pyinstaller website...nothing is helping. Including the selenium module, particularly making an exe that supports firefox, seems impossible. I am starting to pull out my hair because using either py2exe and pyinstaller is becoming a huge headache.

Both py2exe and pyinstaller have their share of problems.

My goal is to make one single exe file, without any extra directories, so that other people can use my program if they do not have python/modules.

With py2exe, if I create a setup.py file as such

from distutils.core import setup
import py2exe

setup(
name='Ask Alfred',
data_files = [('Drivers', ['Drivers/chromedriver.exe',
             'Drivers/webdriver.xpi','Drivers/webdriver_prefs.json'])],
version='1.0',
description='Find emails fast!',
author='Me',
windows=[{'script': 'alphy.py'}],
options={
    'py2exe':
        {
            'skip_archive': False,
            'optimize': 2,
        }
}
)

it will create an exe in the dist folder and a Drivers folder with the files I need, however, if I try to run the exe it will tell me that it could not find these files (because it is looking for them in the library.zip folder). On top of that, my GUI looks terrible (fonts are now grey instead of black and images with white backgrounds now have grey backgrounds).

With pyinstaller, if I use the "--onefile" flag when creating the exe it does not work at all/neither firefox nor chrome gets started.

With either, I only get workable results if I choose to not archive/not make one file. In that case, pyinstaller delivers a fully working solution.

like image 934
ohbrobig Avatar asked Jun 02 '15 06:06

ohbrobig


1 Answers

Try this:

options={
    'py2exe':
        {
            'skip_archive': True,
            'unbuffered': True,
            'bundle_files': 2, #assuming you dont want to include the python interpreter
            'optimize': 2,
        },
},
zipfile = None
like image 177
Rahat Mahbub Avatar answered Sep 28 '22 17:09

Rahat Mahbub