Cx-Freeze:Showwarning AttributeError:'NoneType'对象没有属性'write'

时间:2021-05-22 23:06:01

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:

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

from cx_Freeze import setup, Executable

来自cx_Freeze导入设置,可执行文件

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", line 54, in executemany

DBOps.py“,第54行,在executemany中

"C:\Users\user\Anaconda3\lib\site-packages\MySQLdb\cursors.py", line 286, in executemany File

执行文件中的“C:\ Users \ user \ Anaconda3 \ lib \ site-packages \ MySQLdb \ cursors.py”,第286行

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

“FileC:\ Users \ user \ Anaconda3 \ lib \ site-packages \ MySQLdb \ cursors.py”,第127行,在_warning_check文件“c:\ Python \ 64-bit \ 3.4 \ lib \ warnings.py”中,

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

第15行,在showwarning中出现AttributeError:'NoneType'对象没有属性'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.

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

1 个解决方案

#1


0  

Here is the relevant solution by Thomas Kluyver:

以下是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.

更大的问题是,任何试图显示警告的内容都会导致错误,因为默认情况下它会尝试向sys.stderr写入警告,如果使用Win32GUI库,则没有要写入的stderr。事先调用warnings.simplefilter('ignore')应该可以防止这种情况发生。

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

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

#1


0  

Here is the relevant solution by Thomas Kluyver:

以下是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.

更大的问题是,任何试图显示警告的内容都会导致错误,因为默认情况下它会尝试向sys.stderr写入警告,如果使用Win32GUI库,则没有要写入的stderr。事先调用warnings.simplefilter('ignore')应该可以防止这种情况发生。

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

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