remi icon indicating copy to clipboard operation
remi copied to clipboard

PyInstaller - packaging to exe

Open deshudiosh opened this issue 7 years ago • 13 comments

Hi

When I run app from pycharm everything works fine. After freezing to single EXE with PyInstaller, I get this errors in cmd:

Y:\Python\PyTSF\dist>PyTSF.exe
remi.server      INFO     Started websocket server 127.0.0.11:58965
remi.server      INFO     Started httpserver http://127.0.0.11:8081/
remi.request     ERROR    error processing GET request
Traceback (most recent call last):
  File "site-packages\remi\server.py", line 782, in do_GET
  File "site-packages\remi\server.py", line 628, in _instance
TypeError: invalid file: None
remi.request     ERROR    error processing GET request
Traceback (most recent call last):
  File "site-packages\remi\server.py", line 782, in do_GET
  File "site-packages\remi\server.py", line 628, in _instance
TypeError: invalid file: None
remi.request     ERROR    error processing GET request
Traceback (most recent call last):
  File "site-packages\remi\server.py", line 782, in do_GET
  File "site-packages\remi\server.py", line 628, in _instance
TypeError: invalid file: None

Any Idea how to solve it? I love the lib, but my app gotta be exe.

deshudiosh avatar May 09 '17 01:05 deshudiosh

@deshudiosh I see the error is caused by missing resource files. In particular it could be missing the style.css. How do you pack the exe file? Have you the possibility to specify extra folders to include? If so, you should include the /res folder located in remi library folder

dddomodossola avatar May 09 '17 07:05 dddomodossola

Thanks for quick response. PyInstaller gives option to include files. I'll check this out by the evening. Does Remi search for file like "res/styles.css"? I'll have to include whole path I think.

deshudiosh avatar May 09 '17 09:05 deshudiosh

@deshudiosh Yes, it's better to include the entire path because there are other files included.

dddomodossola avatar May 09 '17 10:05 dddomodossola

I didn't manage to fix the issue. Due to close deadline on project I'll stick to command line interaction for now. I'm gonna get back to it soon. I'll share solution as soon I find one.

deshudiosh avatar May 10 '17 21:05 deshudiosh

any updates on this issue so far ?! I would like to know the steps you did to complete compiling into exe file.

Thanks

AymanEG avatar Dec 27 '17 19:12 AymanEG

Sadly, i gave up on this.

deshudiosh avatar Dec 27 '17 22:12 deshudiosh

I am facing the same issue @deshudiosh thanks for your reply though

remi-gui

AymanEG avatar Dec 28 '17 00:12 AymanEG

Well it is solved with fresh install for python recommended steps as following :

Thanks to @Counterdoc via Gitter Support Chat

-install python (e.g. 3.5.2)
-download remi (master.zip) from github
   1. open cmd and change directory to remi-master
   2. in cmd.exe -> python setup.py install
-install pyinstaller -> cmd.exe -> pip3.5.exe install pyinstaller
-restart computer (just to be safe that new path variables for python are set)
-open cmd and change directory to remi-master/examples
-in cmd.exe -> pyinstaller --onefile widgets_overview_app.py
-now some new files and directories are created
-look for the directory called "dist" -> here is your new widgets_overview_app.exe file!
-important ### -> if you try to start this exe file, your antivirus software might block it! (my did!)
-try to start it without antivirus software -> now the exe should start and also your browser
-finished
-i did all these steps right now (20 minute work) and it is working fine 

In my case the issue was QT5 , although I did not include it in the py file the pyInstaller include it producing a very large exe file around ~ 68 Mb ,now browser is about 6mb and standalone around 10mb

standalone requires to install on windows :

pip install --upgrade --force-reinstall --no-cache-dir pywebview[winforms]

remi-gui-6

and thats all ,happy coding !

AymanEG avatar Dec 29 '17 18:12 AymanEG

@deshudiosh kindly confirm and report back, I am on windows 10 x64 fresh 3.5.2 python install

AymanEG avatar Dec 29 '17 18:12 AymanEG

@AymanEG thank you for details! When I come back to this I'll report if I managed to resolve the issue.

deshudiosh avatar Dec 29 '17 19:12 deshudiosh

I am successful at creating an EXE with no problems now (after I removed PyQt5).

However, the size of the EXE is huge... 188 MB.

I'm not sure what's causing it to be so huge. Can you provide any insight?

MikeTheWatchGuy avatar Jan 26 '19 17:01 MikeTheWatchGuy

Old thread, but in case anyone ever stumbles upon this issue like I did, a simple fix for missing resource files when packaging with PyInstaller is to edit your .spec file as follows:

Add this to the top of the file so you can use the site-packages folder location later on

from os import path
site_packages = next(p for p in sys.path if 'site-packages' in p)

And edit the datas part as follows

datas=[(path.join(site_packages, "remi/res"), "remi/res")]

Now PyInstaller will include a remi/res folder with all the necessary files on dist and you shouldn't get any erros indicating resource files are missing.

PS. Not sure how this pans out for other PyInstaller configurations like --onefile and --onedir, this was tested on the default configurations.

eitchtee avatar Jul 19 '21 03:07 eitchtee

Thank you a lot @eitchtee

dddomodossola avatar Jul 19 '21 05:07 dddomodossola