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

你可能感兴趣的:(python:PyInstaller打包发布单个文件错误struct.error: argument for 's' must be a string解决)