简体   繁体   中英

bottle.py - AttributeError 'NoneType' object has no attribute 'write'

I am using cx_Freeze for the first time. I have used pyinstaller till date but encountered no issue but I need .exe to be working in all windows platforms.

I used this setup code:

from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need
# fine tuning.
buildOptions = dict(packages = [], excludes = [])

import sys
base = 'Win32GUI' if sys.platform=='win32' else None

executables = [
    Executable('app.py', base=base, targetName = 'runme')
]

setup(name='MyApp',
      version = '1.1',
      description = 'None',
      options = dict(build_exe = buildOptions),
      executables = executables)

My imports are as follows:

import pandas as pd
import eel
import bottle_websocket
import tkinter.filedialog
from configparser import ConfigParser
import xlrd

On running the .exe build in cx_Freeze it throws me an error:

"C:\Users\derik\AppData \ Local\ ProgramsWythonWython38-32 \ lib \si te-packages\eel\_init_.py", line 7, 
in <module> import bottle as btl File "<frozen importlib._bootstrap>", line 991, in 
find_and_load File "<frozen importlib._bootstrap>", line 975, in find_and_load_unlocked File "<frozen importlib._bootstrap>", line 655, in load unlocked 
File "<frozen importlib._bootstrap>", line 618, in Load_backward_compatible File "<frozen zipimport>",
 line 259, in load module File "C:\Users\derik\AppData \ Local\ ProgramsPythonPython38-32 \ lib \si te-packages\bottle.py", line 74, in 
<module> 
_stdout, _stderr = sys.stdout.write, sys.stderr.write 
AttributeErron 'NoneType' object has no attribute 'write' 

I was unable to copy the error so this was convert from PNG to text using OCR. You might find few spelling mistakes

Recently I crashed with this issue, using eel, bottle and python 3.11.1

I resolved it by getting the last bottle.py from here http://bottlepy.org/bottle.py and overwriting it on my project

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM