问题
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:\Users\user\Anaconda3\lib\site-packages\MySQLdb\cursors.py", line 286, in executemany File
"FileC:\Users\user\Anaconda3\lib\site-packages\MySQLdb\cursors.py", line 127, in _warning_check File "c:\Python\64-bit\3.4\lib\warnings.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:\Python\64-bit\3.4\lib\warnings.py", since there is no such directory path neither on my system or on server.
回答1:
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
来源:https://stackoverflow.com/questions/35772441/cx-freeze-showwarning-attributeerror-nonetype-object-has-no-attribute-writ