导入re时cx-freeze可执行文件崩溃

时间:2014-01-11 22:36:42

标签: python python-3.x cx-freeze

我有一个小的(<300行)程序,我想捆绑在Windows上发布。遗憾的是,每当我运行可执行文件时,它都会在尝试导入任何内容时失败。它在第一行崩溃,即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 个答案:

答案 0 :(得分:0)

我发现another question有同样的问题,幸运的是同样的解决方案。我将我的安装从3.3.0更新到3.3.3,现在一切都很好。