AttributeError:模块'dis'没有属性'_unpack_opargs'使用CX_FREEZE构建Python 3.6可执行文件时

时间:2017-02-07 19:36:31

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

我一直在尝试将我的Python 3.6程序转换为.EXE。当我使用cx_Freeze构建时。它会生成以下错误。 (见下面的记录)

我之前和Kivy Module一起工作但是在构建失败之后我仍然尝试使用简单的Hello World程序,它失败了。

我的设置文件包含from cx_Freeze import setup, Executable import语句

当我构建python setup.py build时,它会生成此日志。

F:\Python\test>python setup.py build
running build
running build_exe
Traceback (most recent call last):
  File "setup.py", line 7, in 
    executables = [Executable('hello.py')])
  File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cx_Freez
e\dist.py", line 349, in setup
    distutils.core.setup(**attrs)
  File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\distutils\core.py", li
ne 148, in setup
    dist.run_commands()
  File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\distutils\dist.py", li
ne 955, in run_commands
    self.run_command(cmd)
  File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\distutils\dist.py", li
ne 974, in run_command
    cmd_obj.run()
  File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\distutils\command\buil
d.py", line 135, in run
    self.run_command(cmd_name)
  File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\distutils\cmd.py", lin
e 313, in run_command
    self.distribution.run_command(command)
  File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\distutils\dist.py", li
ne 974, in run_command
    cmd_obj.run()
  File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cx_Freez
e\dist.py", line 219, in run
    freezer.Freeze()
  File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cx_Freez
e\freezer.py", line 621, in Freeze
    self.finder = self._GetModuleFinder()
  File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cx_Freez
e\freezer.py", line 333, in _GetModuleFinder
    self.path, self.replacePaths)
  File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cx_Freez
e\finder.py", line 150, in init
    self._AddBaseModules()
  File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cx_Freez
e\finder.py", line 161, in _AddBaseModules
    self.IncludeModule("traceback")
  File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cx_Freez
e\finder.py", line 645, in IncludeModule
    namespace = namespace)
  File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cx_Freez
e\finder.py", line 310, in _ImportModule
    deferredImports, namespace = namespace)
  File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cx_Freez
e\finder.py", line 403, in _InternalImportModule
    parentModule, namespace)
  File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cx_Freez
e\finder.py", line 474, in _LoadModule
    self._ScanCode(module.code, module, deferredImports)
  File "C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cx_Freez
e\finder.py", line 544, in _ScanCode
    method = dis._unpack_opargs if sys.version_info[:2] >= (3, 5) \
AttributeError: module 'dis' has no attribute '_unpack_opargs'

F:\Python\test>

感谢您的帮助。

1 个答案:

答案 0 :(得分:6)

1。打开 档案C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cx_Freeze\finder.py

2。更改(line 544)此处:

   method = dis._unpack_opargs if sys.version_info[:2] >= (3, 5) \
   else self._UnpackOpArgs

为:

   method = self._UnpackOpArgs

3. 保存文件并尝试重新构建;)