Cx-Freeze:Showwarning AttributeError:'NoneType'对象没有属性'write' [英] Cx-Freeze : Showwarning AttributeError: 'NoneType' object has no attribute 'write'

查看:158
本文介绍了Cx-Freeze:Showwarning AttributeError:'NoneType'对象没有属性'write'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过使用Anaconda和Python 3.4,脚本可以在源文件上正常工作.当我cxfreeze(v 4.3.4)时,它带有以下安装文件:

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:

来自cx_Freeze导入设置,可执行

from cx_Freeze import setup, Executable

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

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

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

I got following error on the server:

DBOps.py",executemany中的第54行

DBOps.py", line 54, in executemany

"C:\ Users \ user \ Anaconda3 \ lib \ site-packages \ MySQLdb \ cursors.py",行 286,在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",第127行. py",

"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",

第15行,在showwarning AttributeError中:'NoneType'对象没有属性'write'

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

我认为在系统上安装了不同的python版本可能会导致此问题,请使用安装程序将其删除.没有改变.服务器和lochal机器上的相同错误.错误的部分看起来像"c:\ Python \ 64-bit \ 3.4 \ lib \ warnings.py",因为在我的系统或服务器上都没有这样的目录路径.

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.

推荐答案

这是Thomas Kluyver的相关解决方案:

Here is the relevant solution by Thomas Kluyver:

更大的问题是,任何试图显示 警告将导致错误,因为默认情况下它将尝试写入 sys.stderr警告,如果您使用Win32GUI base,则没有 要写的stderr.预先调用warnings.simplefilter('ignore') 应该防止这种情况.

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

这篇关于Cx-Freeze:Showwarning AttributeError:'NoneType'对象没有属性'write'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆