Welcome to OGeek Q&A 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 Reply

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...