Creating an Exe with Selenium Module: Py2exe/Pyinstaller

纵饮孤独 提交于 2019-12-03 05:17:45

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/30589329/creating-an-exe-with-selenium-module-py2exe-pyinstaller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!