0

I have a problem with Pyinstaller, when I build the program everything works fine, but when I publish files on github or archive.org and download from there, when I try to run it, an error

Traceback (most recent call last):
  File "my_app.py", line 28, in <module>
    webview.start(gui="edgechromium", debug=False)
  File "webview\__init__.py", line 174, in start
  File "webview\guilib.py", line 134, in initialize
  File "webview\guilib.py", line 83, in try_import
  File "webview\guilib.py", line 72, in import_winforms
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
  File "webview\platforms\winforms.py", line 13, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
  File "clr.py", line 6, in <module>
  File "pythonnet\__init__.py", line 143, in load
  File "clr_loader\types.py", line 94, in get_function
  File "clr_loader\types.py", line 58, in __init__
  File "clr_loader\netfx.py", line 47, in _get_callable
RuntimeError: Failed to resolve Python.Runtime.Loader.Initialize from C:\Users\[USERNAME]\Downloads\application_folder\pythonnet\runtime\Python.Runtime.dll

my code:

import os
import sys
import webview
from pathlib import Path

HERE = Path(__file__).resolve().parent
INDEX = HERE / "launcher" / "index.html"     
if not INDEX.exists():
    raise FileNotFoundError(
        f"{INDEX} not found."
    )

url = INDEX.as_uri()

os.environ["WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS"] = \
    "--autoplay-policy=no-user-gesture-required"

window = webview.create_window(
    title="ChickenFine",   
    url=url,               
    fullscreen=True,       
    frameless=True,        
    resizable=True,        
    confirm_close=False    
)

# edgechromium
webview.start(gui="edgechromium", debug=False)

I don't know what to do with this Can you tell me what the problem is?

3
  • Python wasn't created to make .exe file and programs like Pyinstaller often have problem to find all needed Python modules or C/C++ libraries which will be needed on other computer. You may see many question about Pyinstaller on Stackoverflow. Maybe you should search on Stackoverflow if someone already had similar problem. Probably problem is edge chromium. Commented Sep 14 at 14:08
  • last line of error may shows problem with Python.Runtime.dll. Maybe it can't find it or this Python.Runtime.dll tried to load some other file (maybe other .dll) which it couldn't find (because PyIntaller didn't know that it has to add it to .exe and it may need to find out what file(s) it may need and add them manually to PyInstaller .spec file) Commented Sep 14 at 14:15
  • @Zroz did you find a solution for this? I'm running into the same thing with my app that uses pywebview and pyinstaller. Webview works fine during development and on the machine that does the build, but running the EXE on other machines is super inconsistent and often causes webview to fail. Commented Oct 5 at 18:24

1 Answer 1

0

You can try doing a few things to avoid this type of issues:

  1. Make sure your requirements.txt is up to date.

  2. You can try containerizing your application and run it using docker.

These approaches are specifically designed to resolve such issues.

Let me know if you need more help!

Sign up to request clarification or add additional context in comments.

1 Comment

I would say that it is good for comment, not for answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.