Maryam Balti
Maryam Balti

Reputation: 41

Why my packaged eel app failed to execute : AttributeError: 'NoneType' object has no attribute 'write'

I keep getting this error when trying to execute my app.exe ( generated with python -m eel [your_main_script] [your_web_folder] --onefile --noconsole)

My code is too long to post here.

Here is the full unhandled exception thrown where tempting to execute the app

Traceback (most recent call last):
  File "survey.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 "eel\__init__.py", line 8, 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'

My libraries have been updated and I checked that I'm writing in files with valid paths

Upvotes: 2

Views: 4156

Answers (3)

I solved this problem!

C:\Users\user\AppData\Local\Programs\Python\Python310\Lib\site-packages\bottle.py -> Comment out this code!:

Line 73:

try: _stdout, _stderr = sys.stdout.write, sys.stderr.write except IOError: _stdout = lambda x: sys.stdout.write(x) _stderr = lambda x: sys.stderr.write(x)

Upvotes: 0

Maryam Balti
Maryam Balti

Reputation: 41

I overwrote the bottle.py files located in my python installation directory with this content https://github.com/bottlepy/bottle/blob/master/bottle.py and it worked for me

Upvotes: 2

J-Mully
J-Mully

Reputation: 11

This fixed it for me, seems to be a problem with sys.stdout when using --windowed pyinstaller (with no console to output to) so stdout == None.

https://github.com/bottlepy/bottle/commit/5e2efb6ad9c12d986c59926d0b3f99be003189d0

Upvotes: 1

Related Questions