cx-freeze 可执行文件在导入 re 时崩溃
Posted
技术标签:
【中文标题】cx-freeze 可执行文件在导入 re 时崩溃【英文标题】:cx-freeze executable crashes on importing re 【发布时间】:2014-01-11 22:36:41 【问题描述】:我有一个小型(import re, configparser as conf。
c:\Python33\opencourses\dist>.\opencourses.exe
Traceback (most recent call last):
File "C:\Python33\lib\site-packages\cx_Freeze\initscripts\Console3.py", line 2
7, in <module>
exec(code, m.__dict__)
File "opencourses.py", line 19, in <module>
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 1567, in _find_a
nd_load
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 1534, in _find_a
nd_load_unlocked
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 497, in set_pack
age_wrapper
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 510, in set_load
er_wrapper
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 608, in _require
s_frozen_wrapper
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 713, in load_mod
ule
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 313, in _call_wi
th_frames_removed
File "C:\Python\64-bit\3.3\lib\re.py", line 122, in <module>
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 1567, in _find_a
nd_load
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 1534, in _find_a
nd_load_unlocked
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 497, in set_pack
age_wrapper
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 510, in set_load
er_wrapper
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 608, in _require
s_frozen_wrapper
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 713, in load_mod
ule
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 313, in _call_wi
th_frames_removed
File "C:\Python\64-bit\3.3\lib\sre_compile.py", line 14, in <module>
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 1567, in _find_a
nd_load
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 1534, in _find_a
nd_load_unlocked
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 497, in set_pack
age_wrapper
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 510, in set_load
er_wrapper
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 608, in _require
s_frozen_wrapper
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 713, in load_mod
ule
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 313, in _call_wi
th_frames_removed
File "C:\Python\64-bit\3.3\lib\sre_parse.py", line 17, in <module>
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 1567, in _find_a
nd_load
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 1534, in _find_a
nd_load_unlocked
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 497, in set_pack
age_wrapper
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 510, in set_load
er_wrapper
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 608, in _require
s_frozen_wrapper
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 713, in load_mod
ule
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 313, in _call_wi
th_frames_removed
File "C:\Python\64-bit\3.3\lib\sre_constants.py", line 18, in <module>
ImportError: cannot import name MAXREPEAT
编辑: 实际上,是 re
模块导致了问题。我通过更改首先导入的模块进行了测试——time
导入正常,但 urllib
以某种方式依赖于 re
,失败并出现类似错误。
Traceback (most recent call last):
File "C:\Python33\lib\site-packages\cx_Freeze\initscripts\Console3.py", line 2
7, in <module>
exec(code, m.__dict__)
File "opencourses.py", line 20, in <module>
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 1616, in _handle
_fromlist
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 313, in _call_wi
th_frames_removed
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 1567, in _find_a
nd_load
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 1534, in _find_a
nd_load_unlocked
File "C:\Python33\lib\urllib\request.py", line 84, in <module>
import base64
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 1567, in _find_a
nd_load
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 1534, in _find_a
nd_load_unlocked
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 497, in set_pack
age_wrapper
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 510, in set_load
er_wrapper
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 608, in _require
s_frozen_wrapper
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 713, in load_mod
ule
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 313, in _call_wi
th_frames_removed
File "C:\Python\64-bit\3.3\lib\base64.py", line 9, in <module>
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 1567, in _find_a
nd_load
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 1534, in _find_a
nd_load_unlocked
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 497, in set_pack
age_wrapper
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 510, in set_load
er_wrapper
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 608, in _require
s_frozen_wrapper
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 713, in load_mod
ule
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 313, in _call_wi
th_frames_removed
File "C:\Python\64-bit\3.3\lib\re.py", line 122, in <module>
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 1567, in _find_a
nd_load
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 1534, in _find_a
nd_load_unlocked
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 497, in set_pack
age_wrapper
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 510, in set_load
er_wrapper
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 608, in _require
s_frozen_wrapper
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 713, in load_mod
ule
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 313, in _call_wi
th_frames_removed
File "C:\Python\64-bit\3.3\lib\sre_compile.py", line 14, in <module>
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 1567, in _find_a
nd_load
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 1534, in _find_a
nd_load_unlocked
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 497, in set_pack
age_wrapper
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 510, in set_load
er_wrapper
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 608, in _require
s_frozen_wrapper
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 713, in load_mod
ule
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 313, in _call_wi
th_frames_removed
File "C:\Python\64-bit\3.3\lib\sre_parse.py", line 17, in <module>
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 1567, in _find_a
nd_load
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 1534, in _find_a
nd_load_unlocked
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 497, in set_pack
age_wrapper
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 510, in set_load
er_wrapper
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 608, in _require
s_frozen_wrapper
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 713, in load_mod
ule
File "C:\Python\64-bit\3.3\lib\importlib\_bootstrap.py", line 313, in _call_wi
th_frames_removed
File "C:\Python\64-bit\3.3\lib\sre_constants.py", line 18, in <module>
ImportError: cannot import name MAXREPEAT
遗憾的是,这意味着我无法解决我自己的 re
依赖,因为其他模块也依赖它:(
【问题讨论】:
【参考方案1】:我发现another question 有同样的问题,幸运的是同样的解决方案。我将我的安装从 3.3.0 更新到 3.3.3,现在一切正常。
【讨论】:
以上是关于cx-freeze 可执行文件在导入 re 时崩溃的主要内容,如果未能解决你的问题,请参考以下文章
使用 matplotlib 时来自 cx-freeze 的运行时错误