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

Multiprocessing error in windows bundle #10

Open
jordanvaneetveldt opened this issue Jan 18, 2023 · 6 comments
Open

Multiprocessing error in windows bundle #10

jordanvaneetveldt opened this issue Jan 18, 2023 · 6 comments
Assignees

Comments

@jordanvaneetveldt
Copy link

Hello,

I am trying to bundle my trame application into a windows exe. I followed the README steps in bundles/desktop/windows. When I run run.py everything works fine. Then I managed to create the exe with pyinstaller but when I execute it I get the following error:

  File "multiprocessing\process.py", line 314, in _bootstrap
  File "trame_server\utils\desktop.py", line 26, in run
  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\__init__.py", line 22, 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 "webview\http.py", line 1, 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 "bottle.py", line 73, in <module>
AttributeError: 'NoneType' object has no attribute 'write'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "run.py", line 5, in <module>
  File "Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_multiprocessing.py", line 49, in _freeze_support
  File "multiprocessing\spawn.py", line 116, in spawn_main
  File "multiprocessing\spawn.py", line 129, in _main
  File "multiprocessing\process.py", line 329, in _bootstrap
AttributeError: 'NoneType' object has no attribute 'write'

Problem seems to be with the freeze_support(). However when I delete it I have an infinite recursion.
Do you know how to solve this?

Thanks in advance

@psavery
Copy link
Collaborator

psavery commented Jan 18, 2023

This actually appears to be an issue with bottle used with pyinstaller. Note that the first exception occurred first, and then the second exception occurred while trying to handle the first.

Line 73 (where the error occurred) of the bottle.py source looks like this:

    _stdout, _stderr = sys.stdout.write, sys.stderr.write

From looking online, it appears that pyinstaller in windows applications sometimes sets sys.stderr to be None. Why, I'm not sure. But it appears that the error is occurring in bottle because it is trying to access write on sys.stderr when it is None.

@jourdain
Copy link
Collaborator

@Guarouba Any reason why bottle.py is involved here?

@jordanvaneetveldt
Copy link
Author

@jourdain bottle is a dependency of pywebview.

@jourdain
Copy link
Collaborator

Hum, I'm only seeing a dependency on webview

@jordanvaneetveldt
Copy link
Author

bottle is a dependency of pywebview==4.0.1. Using pywebview==3.7.2 fixed the problem. Thanks for the support.

@psavery
Copy link
Collaborator

psavery commented Jan 20, 2023

Indeed, it does appear to be a dependency of pywebview.

We'll probably need to post an issue upstream somewhere (bottle? pyinstaller?) about this issue. I don't think it is something we can fix on our end.

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

No branches or pull requests

3 participants