Ser*_*giy 5 python matplotlib beautifulsoup cx-freeze
我正在尝试使用cxFreeze为我的python脚本编译可执行文件.在我需要为我的脚本导入的许多库中,有两个似乎与cxFreeze失败了.特别要考虑以下test.py脚本:
print('matplotlib.pyplot')
import matplotlib.pyplot
Run Code Online (Sandbox Code Playgroud)
使用cxFreeze进行编译并运行时会提供以下输出:
另外,以下test.py脚本:
print('BeautifulSoup from bs4')
from bs4 import BeautifulSoup
Run Code Online (Sandbox Code Playgroud)
用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)]
)
Run Code Online (Sandbox Code Playgroud)
我正在运行Python 3.3 x86,并在Windows 7上使用32位版本的cxFreeze(最新版本).
我在追逐这个问题时遇到了麻烦.首先,我的计算机上不存在目录"C:\ Python\32-bit ...",因此我不清楚为什么cxFreeze试图查看那里.有没有人知道如何处理这个问题,或者已经处理过这个问题?
经过一番挖掘,我能够解决这个问题.对于那些可能遇到同样问题的人来说,这就是为我解决的问题:
对于matplotlib的问题:我只需要明确指定cxFreeze来包含matplotlib.backends.backend_tkagg.我的安装文件最终看起来像这样:
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)]
)
Run Code Online (Sandbox Code Playgroud)
至于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并解决问题,但我没有尝试这个解决方案.
| 归档时间: |
|
| 查看次数: |
2500 次 |
| 最近记录: |