简体   繁体   中英

AttributeError: module 'dis' has no attribute '_unpack_opargs' While Building Python 3.6 executable using CX_FREEZE

I have been trying to Convert my Python 3.6 Programs into.EXE. When I build using cx_Freeze. It generates the following error. (See Log Below)

I was earlier working with Kivy Module but after the build failed repeatedly I tried it with simple Hello World Program still, It failed.

My setup file contains from cx_Freeze import setup, Executable import statement,

When I build through python setup.py build It generates this log.

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>

Thanks for your Help.

1. Open File C:\\Users\\UserName\\AppData\\Local\\Programs\\Python\\Python35-32\\lib\\site-packages\\cx_Freeze\\finder.py :

2. Change (at line 544 ) this:

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

to:

   method = self._UnpackOpArgs

3. Save the file and try to build again ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM