r0x0r / pywebview

Build GUI for your Python program with JavaScript, HTML, and CSS
https://pywebview.flowrl.com
BSD 3-Clause "New" or "Revised" License
4.73k stars 554 forks source link

Path /index.html was not found after package(pyinstaller) #625

Closed Voyage-He closed 4 years ago

Voyage-He commented 4 years ago

Specification

Description

I test a demo from doc

import webview

window = webview.create_window('Woah dude!', 'index.html') webview.start(http_server=True)


really awesome project among so many webview implementations! But in Python, generating exe is a big problem.....

Voyage-He commented 4 years ago

Snipaste_2020-10-22_13-32-37 Snipaste_2020-10-22_13-36-08

r0x0r commented 4 years ago

I agree that generating an exe in Python is a big problem.

pywebview has a basic support for freezing with Pyinstaller, but this is about it. Other freezing solutions either have not been tested or proved to be too much work. However, I have nothing against support for freezing solutions, if somebody has got energy for research and investigation.

Maybe you could start by first stating what freezing solution you tried.

Voyage-He commented 4 years ago

Thank you for your reply!

As I said in the title of this issue, I used pyinstaller. I'm afraid that maybe I made a silly mistake, so I describe my problem more detailed.

|--- index.html |--- demo.py it does work with 'python demo.py' command

then 'pyinstaller -F demo.py' |--- index.html |--- demo.exe error of 'path /index.html was not found' occured after running demo.exe

Your criticism is welcome.

r0x0r commented 4 years ago

Oh sorry the mail client truncated the title, so did not notice the pyinstaller bit.

Does it work without the onefile option?

Voyage-He commented 4 years ago

With -F or without -F With http_server or without http_server And I try to put html file in an ‘assets’ directory These all didn’t work

Actually, the thing I want to know most is whether this situation only appears to me? If so, I may consider more about the problem of MY environment, or my computer Maybe, I should try to restart from reinstalling python. haha

r0x0r commented 4 years ago

I will check paths when I get a chance.

The thing with one file is that you have to include your asset inside your executable using the data switch. Placing it along the exe file would not work.

r0x0r commented 4 years ago

Bad news. My Windows machine broke so I am not able to look into this at the moment.

r0x0r commented 4 years ago

I managed to test it and this is caused by the assets dir not being included with pyinstaller. Look into the Adding files section of pyinstaller docs. https://pyinstaller.readthedocs.io/en/stable/spec-files.html

Voyage-He commented 4 years ago

Thank you soooo much!