python-eel / Eel

A little Python library for making simple Electron-like HTML/JS GUI apps
MIT License
6.44k stars 587 forks source link

App Packing: Eel & Selenium #358

Closed mihneamanolache closed 1 year ago

mihneamanolache commented 4 years ago

Hi. I built a small app using Eel and selenium (among others) but when I pack it using pyinstaller it simply closes. Here is what my app 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
import sys
import subprocess
import eel
import gspread
from gspread_dataframe import set_with_dataframe

In order to pack the app I am using the following command (on mac): python3 -m eel raportarismart.py web --noconsole --onefile --icon=icon.icns

Question: Could you please let me know what I am doing wrong and maybe how I can pack the app? Thanks!

P.S. Since I am using selenium, I am guessing that I should somehow include the chromedriver in PyInstaller, but I don't really know how. Same should apply to the json file used for gspread.

Thanks in advance!

Later edit: This is how the directory looks like, should this help:

|____icon.icns
|____.DS_Store
|____updateDB.py
|____driver
| |____chromedriver.exe
| |____chromedriver
|____web
| |____index.html
| |____.DS_Store
| |____css
| | |____bootstrap.min.css
| |____img
| | |____.DS_Store
| | |____bg-img
| | | |____a3ca141c-event-arrows-bg.png
| |____main.js
| |____ExportZilnic.txt
| |____style.css
|____MyApp.py
|____README.md
|____setup.py
|____credentials.json
|____MyApp.spec
samuelhwilliams commented 4 years ago

Hi @mihneamanolache - sorry for the slow reply. Have you fixed this yet? Try building it without the --noconsole and --onefile flags first and you should be able to understand the errors better. Including the chromedriver executable feels likely, yes. Have a look at PyInstaller docs directly for how to include extra files.

mihneamanolache commented 4 years ago

Thanks, @samuelhwilliams! I will try and let you know what the outcome was.

CombatVolcano commented 4 years ago

Are you blocking with .init and .start in your main? It is likely that the last 2 lines of your main statement will be eel.init('folder') and eel.start('file'). That is the basic arena.

I use selenium and eel with pyinstaller without issues. You don't need a pyinstaller reference for Selenium (except any hidden imports), but you do have to point at the driver file on the users machine. There are various ways to package the chromedriver into pyinstaller but I highly recommend just having your software download the latest version from a remote because it updates all the time whenever chrome updates and they are not backwards compatible. (software no longer works every new chrome version)

For compiling eel with pyinstaller the eel documentation is exactly right... if you begin with the example you should be fine.