我有一个小的(<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
依赖问题,因为其他模块也依赖于它:(