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

eel not working when using cx_freeze #371

Open kakaroto opened 4 years ago

kakaroto commented 4 years ago

Eel version master

Describe the bug When using cx_freeze to freeze the app, it will fail to start due to sys._MEIPASS not being defined

Additional context in eel/__init__.py , you check for whether the app was frozen in get_real_path and use sys._MEIPASS if that's the case. However, that only works specifically for pyinstaller. In the case of cx_freeze, the app is considered frozen but there is no _MEIPASS defined and you can use the path normally.

I tracked down the bug and the issue to a similar fix in another project and you can see their fix for it here : https://github.com/bokeh/bokeh/pull/8324/files

Adding and hasattr(sys, '_MEIPASS'): to line 297 of init.py (https://github.com/samuelhwilliams/Eel/blob/master/eel/__init__.py#L297) fixed it for me and I can confirm that eel is working (and it's working great!) I didn't feel like such a small change deserved for me to do a fork and PR but if you'd prefer I do that, let me know and I can send you a PR instead.

samuelhwilliams commented 4 years ago

Can I ask why you need to use cx_freeze rather than pyinstaller?

kakaroto commented 4 years ago

Because of the thousand users I've had, about 25% of them had issues with pyinstaller. For example, for some, it will simply not open anything, I've had to remote desktop into a user's PC and could not figure it out, the process starts then exits, no output in console, or anything. It also doesn't load at all for me if the exe is launched from within a network drive, also, I've had multiple times where the generated exe was getting flagged as a virus by various antivirus software, such as Windows Defender. I also need to generate a dmg for Mac builds, and I think pyinstaller only supports generating a .app, I like that cx_freeze can do the dmg process generation for as well.

Overall, I've been using pyinstaller for nearly a year and grew tired of fighting against it, tried cx_freeze, it gives bigger files (a 300MB instead of 95MB directory) due to how it brings in pyside dependencies (still trying to figure out how to remove that dep), but otherwise, when pyinstaller wasn't working for people, cx_freeze was working fine. I gave pyinstaller a try, now I want to give cx_freeze a try.

Regardless, there are multiple freezing choices in the python community, and giving the choice of the user seems sensible rather than forcing a single choice :) I hope that helps you understand why I made that choice. Thanks!

funatsufumiya commented 1 year ago

Can I ask why you need to use cx_freeze rather than pyinstaller?

I use cx_freeze rather than pyinstaller in some cases. Pyinstaller executable sometimes takes much time to start up than cx_freeze.

I created another pull request. https://github.com/python-eel/Eel/pull/635