Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.6k views
in Technique[技术] by (71.8m points)

mysql - Cx-Freeze : Showwarning AttributeError: 'NoneType' object has no attribute 'write'

Scripts works fine on source file with using Anaconda alongside with Python 3.4. When i cxfreeze (v 4.3.4) it with following setup file:

from cx_Freeze import setup, Executable

setup(executables=[Executable("main.py", base="Win32GUI")], version='0.2')

I got following error on the server:

DBOps.py", line 54, in executemany

"C:UsersuserAnaconda3libsite-packagesMySQLdbcursors.py", line 286, in executemany File

"FileC:UsersuserAnaconda3libsite-packagesMySQLdbcursors.py", line 127, in _warning_check File "c:Python64-bit3.4libwarnings.py",

line 15, in showwarning AttributeError: 'NoneType' object has no attribute 'write'

I thougth different python versions installed on my system might result this problem, removed them by using installer. Nothing changed. Same error on both server and lochal machines. The errorneous part seems like "c:Python64-bit3.4libwarnings.py", since there is no such directory path neither on my system or on server.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Here is the relevant solution by Thomas Kluyver:

The bigger issue there is that anything that attempts to show a warning will cause an error, because by default it tries to write warnings to sys.stderr, and if you use the Win32GUI base, there's no stderr to write to. Calling warnings.simplefilter('ignore') beforehand should prevent that.

source:https://bitbucket.org/anthony_tuininga/cx_freeze/issues/81/python-34-venv-importlib-attributeerror


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...