Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyinstaller After compilation erro #1029

Closed
zd20041 opened this issue Feb 4, 2023 · 7 comments · Fixed by #1048
Closed

pyinstaller After compilation erro #1029

zd20041 opened this issue Feb 4, 2023 · 7 comments · Fixed by #1048

Comments

@zd20041
Copy link

zd20041 commented Feb 4, 2023

Specification

  • pywebview version: 4.0.1
  • operating system: win11 20h2
  • web renderer: I don't know

Description

code
import webview
webview.create_window('Hello world', 'https://pywebview.flowrl.com/')
webview.start()

error
Traceback (most recent call last):
File "test1.py", line 1, in
File "", line 1007, in _find_and_load
File "", line 986, in _find_and_load_unlocked
File "", line 680, in load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
File "webview_init
.py", line 22, in
File "", line 1007, in _find_and_load
File "", line 986, in _find_and_load_unlocked
File "", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
File "webview\http.py", line 1, in
File "", line 1007, in _find_and_load
File "", line 986, in _find_and_load_unlocked
File "", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
File "bottle.py", line 73, in
AttributeError: 'NoneType' object has no attribute 'write'

@zd20041
Copy link
Author

zd20041 commented Feb 4, 2023

compile cmd : pyinstaller -F -w main.py

@simonrob
Copy link
Contributor

simonrob commented Feb 8, 2023

The same issue has been reported on a project of mine. I believe it is related to this change in PyInstaller 5.7.0 which now handles stdout and stderr in the same way as pythonw would (i.e., they are None). The exception actually happens with bottle, but the previous discussion of this sort of thing over there suggests it is down to the end user (i.e., pywebview) to handle this, rather than that package.

Replicate by compiling the pywebview hello world example with pyinstaller --noconsole --onefile demo.py.

@r0x0r
Copy link
Owner

r0x0r commented Feb 8, 2023

I have implemented a fix based on one of linked discussions in the https://github.com/r0x0r/pywebview/tree/logwriter-bottle branch. Please test.

@zd20041
Copy link
Author

zd20041 commented Feb 9, 2023

我已经根据 https://github.com/r0x0r/pywebview/tree/logwriter-bottle 分支中的链接讨论之一实施了修复程序。请测试。
This version is no problem, thanks (๑•̀ㅂ•́)و✧

@zd20041 zd20041 closed this as completed Feb 9, 2023
simonrob added a commit to simonrob/pywebview that referenced this issue Feb 16, 2023
Bottle.py versions prior to 0.12.23 (the latest on PyPi as of Feb 2023) require stdout and stderr to exist when that package is imported, which is not the case on Windows when using pythonw.exe or PyInstaller >= 5.8.0.
This is similar to the recently-merged PR r0x0r#1038 that fixed r0x0r#1029, but this fix only works if using bottle.py 0.13-dev, which is unlikely in most cases given that this version is not on PyPi (note that the fix it contains was committed over two years ago in January 2021).
This change uses a `TemporaryFile` instead of `DummyLogWriter` to resolve the issue.
Fixes r0x0r#1044.
@zd20041 zd20041 reopened this Feb 18, 2023
@zd20041
Copy link
Author

zd20041 commented Feb 18, 2023

所有者

this branch -w is available

I won't use github

Do I have to do something?

Because I found that I still get the issue of -w error when downloading the latest version using pip

Including the pywebview[qt] version -w also has this problem
I'm sorry
Trouble for you

@zd20041
Copy link
Author

zd20041 commented Feb 19, 2023

When will this branch be released to pip?

@r0x0r
Copy link
Owner

r0x0r commented Feb 22, 2023

@zd20041 now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants