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

标签 mysql python-3.x mysql-python anaconda cx-freeze

脚本在使用 Anaconda 和 Python 3.4 的情况下在源文件上运行良好。当我使用以下安装文件 cxfreeze (v 4.3.4) 时:

from cx_Freeze import setup, Executable

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

我在服务器上遇到以下错误:

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'

我想我的系统上安装的不同 python 版本可能会导致这个问题,使用安装程序删除它们。没有改变。服务器和本地计算机上的相同错误。错误的部分看起来像“c:\Python\64-bit\3.4\lib\warnings.py”,因为在我的系统或服务器上都没有这样的目录路径。

最佳答案

这是 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.

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

关于mysql - Cx-卡住 : Showwarning AttributeError: 'NoneType' object has no attribute 'write' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35772441/

相关文章:

mysql - 尝试将一个值插入一列的一行时出现 SQL 错误

python - 属性错误: module 'pymysql.constants.ER' has no attribute 'CONSTRAINT_FAILED' in pymysql Python

mysql - 我试图了解如何使用 TFDStoredProc(FireDac 组件)填充 TIWDBGrid(IntraWeb 组件)

mysql - 如何根据每个 id 更新所有行

python - url django 中渲染的 slugs 不正确

python - 如何在 Python 和 QML 之间引用自定义角色索引

python - 从多个 tkinter 选项菜单中获取值

Python3 - Pipenv 安装 mysqlclient?

python - 无法在 python 线程中连接到 MySQL(在主线程上正常)

mysql - 从sql表中按日期顺序对重复值求和