rawpython / remi

Python REMote Interface library. Platform independent. In about 100 Kbytes, perfect for your diet.
Apache License 2.0
3.53k stars 402 forks source link

PyInstaller - packaging to exe #183

Open deshudiosh opened 7 years ago

deshudiosh commented 7 years ago

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.

dddomodossola commented 7 years ago

@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

deshudiosh commented 7 years ago

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.

dddomodossola commented 7 years ago

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

deshudiosh commented 7 years ago

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.

AymanEG commented 6 years ago

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

Thanks

deshudiosh commented 6 years ago

Sadly, i gave up on this.

AymanEG commented 6 years ago

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

remi-gui

AymanEG commented 6 years ago

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 commented 6 years ago

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

deshudiosh commented 6 years ago

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

MikeTheWatchGuy commented 5 years ago

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?

eitchtee commented 3 years ago

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.

dddomodossola commented 3 years ago

Thank you a lot @eitchtee