我正在尝试使用cxFreeze为我的python脚本编译可执行文件。在我需要为脚本导入的许多库中,有两个似乎因cxFreeze而失败。特别是,请考虑以下test.py脚本:
print('matplotlib.pyplot')
import matplotlib.pyplot
使用cxFreeze编译并运行可得到以下输出:
分别使用以下test.py脚本:
print('BeautifulSoup from bs4')
from bs4 import BeautifulSoup
用cxFreeze编译后,产生以下输出:
我的cxFreeze的setup.py文件如下所示:
import sys
from cx_Freeze import setup, Executable
setup(
name = "myname",
version = "1.0",
description = "some description",
executables = [Executable("test.py", base = None)]
)
我正在运行Python 3.3 x86,并且在Windows 7上使用32位版本的cxFreeze(最新)。
I am having trouble chasing down this issue. For one, the directory "C:\Python\32-bit..." doesn't exist on my computer, so I am unclear as to why cxFreeze is trying to look there. Does anyone have any idea how to approach this, or perhaps has already dealt with this issue?
After some digging around, I was able to resolve the issue. For those who may be encountering the same issue, this is what solved it for me:
For the issue with matplotlib: I simply needed to explicitly specify to cxFreeze to include matplotlib.backends.backend_tkagg. My setup file ended up looking like this:
import sys
from cx_Freeze import setup, Executable
packages = ['matplotlib.backends.backend_tkagg']
setup(
name = "myname",
version = "1.0",
description = "some description",
options = {'build_exe': {'packages':packages}},
executables = [Executable("test.py", base = None)]
)
至于BeautifulSoup问题:网络上有几篇有关此问题的文章:cx_freeze sre_constants.error不再重复,https : //bitbucket.org/anthony_tuininga/cx_freeze/issue/59/sre_constantserror-nothing-重复。相关结论:导致此问题的cxFreeze 4.3.2构建存在问题。我只是用cxFreeze 4.3.1来构建我的应用程序,问题就解决了。也可以在本地重建4.3.2并解决问题,但我没有尝试此解决方案。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句