Could you please tell me how I can make a standalone pyinstaller
app / what I should write in setup.py in oreder to make my app work with pyinstaller
. Here is what my python script uses
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException
import pandas as pd
import random
import time
import math
import os, sys, subprocess
import eel
Note: my script uses an .xlsx file, a .txt file and since the GUI is built with eel
, some .html, .css, .js files (located under ./web/...)
Here is how my setup.py looks like now:
from setuptools import setup
APP = ['RaportariSmart.py']
DATA_FILES = ['Scoala.xlsx', './driver/chromedriver', './driver/chromedriver.exe', './web/ExportZilnic.txt', './web/index.html', './web/main.js', './web/style.css', './web/img/a3ca141c-event-arrows-bg.png', './web/css/bootstrap.min.css']
OPTIONS = {'includes':['selenium', 'eel', 'pandas', 'os', 'sys', 'subprocess']}
setup(
name='Raporari Smart',
version='1.0.0',
author='Mihnea Manolache',
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
Issue: Whenever I pack the app with pyinstaller
, it simply closes.
P.S. I used the same script on a tkinter
app and I managed to pack it successfully, but I cannot make it work with eel
.
I know it is really late, but if you are using PyInstaller try using spec file. Add your source of .exe file and destination of .exe file in binaries NOT in datas.
Here is a small snippet from the spec file.
a = Analysis(['app.py'],
pathex=['D:\\tmp\\testProjects\\testEel'],
binaries=[('venv\\Lib\\site-packages\\webdrivermanager\\87\\chromedriver.exe', '.')],
datas=[('D:\\tmp\\testProjects\\testEel\\venv\\lib\\site-packages\\eel\\eel.js', 'eel'), ('web', 'web')],
hiddenimports=['bottle_websocket'],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
Run PyInstaller app.py
If the problem still persists probably you have given an incorrect path for webdriver
in your program.
Also, I think it is better if you could download webdrivers on the machine automatically based on their browser version instead of providing a particular version with a .exe file.
There is this cool module that does download web drivers for the appropriate version, so you won't have to add web drivers to the .exe file webdrivermanager. Change the download location of the web driver and point it to that path in the program.