1. 程式人生 > >python:PyInstaller打包釋出單個檔案錯誤struct.error: argument for 's' must be a string解決

python:PyInstaller打包釋出單個檔案錯誤struct.error: argument for 's' must be a string解決

用PyInstaller的-F選項打包程式為單個檔案時報錯了,經過研究已經解決

檔案C:\Python27\Lib\site-packages\PyInstaller-2.1-py2.7.egg\PyInstaller\loader\pyi_carchive.py 中第85行進行修改


nmlen + entrylen, dpos, dlen, ulen, flag, typcd, nm + pad))

修改為

nmlen + entrylen, dpos, dlen, ulen, flag, typcd, str(nm) + pad))

修改後使用"pyinstaller -w -F test.py"測試就正常了

錯誤資訊如下:

    self.assemble()

  File "C:\Python27\lib\site-packages\pyinstaller-2.1-py2.7.egg\PyInstaller\build.py", line 1069, in assemble
    archive.build(self.name, mytoc)
  File "C:\Python27\lib\site-packages\pyinstaller-2.1-py2.7.egg\PyInstaller\loader\pyi_archive.py", line 217,
in build
    self._finalize()
  File "C:\Python27\lib\site-packages\pyinstaller-2.1-py2.7.egg\PyInstaller\loader\pyi_carchive.py", line 190,
 in _finalize
    self.save_toc(toc_pos)
  File "C:\Python27\lib\site-packages\pyinstaller-2.1-py2.7.egg\PyInstaller\loader\pyi_carchive.py", line 351,
 in save_toc
    tocstr = self.toc.tobinary()
  File "C:\Python27\lib\site-packages\pyinstaller-2.1-py2.7.egg\PyInstaller\loader\pyi_carchive.py", line 85,
in tobinary
    nmlen + entrylen, dpos, dlen, ulen, flag, typcd, nm + pad))
struct.error: argument for 's' must be a string