PyInstaller断言错误 - 用于工作正常,现在它不

时间:2016-06-21 18:20:14

标签: python python-3.x windows-10 pyinstaller

我正在尝试使用PyInstaller。我曾经在同一个系统上多次使用它,并且能够成功地将我的程序打包到.exe文件中,但是现在有些东西不起作用,我不确定是什么改变了。

它给了我一些错误(“TypeError: a bytes-like object is required, not 'str'”多次出现),但我很陌生,我不明白他们的意思或做些什么。所以我只是发布整个该死的输出,希望有人能告诉我如何解决这个问题。

对于我尝试使用PyInstaller打包的每个程序都会发生同样的错误,无论程序使用什么模块。即使是不导入任何东西的简单测试程序也会给我同样的错误。无论我使用--onefile命令还是将其保留,都会发生这种情况。

这是整个丑陋的事情:

    PS C:\Users\BashfaceTheTruncheon\desktop\learn_python> PyInstaller --onefile timetorun.py
127 INFO: PyInstaller: 3.2
128 INFO: Python: 3.5.1
129 INFO: Platform: Windows-10-10.0.10586-SP0
131 INFO: wrote C:\Users\BashfaceTheTruncheon\desktop\learn_python\timetorun.spec
135 INFO: UPX is not available.
138 INFO: Extending PYTHONPATH with paths
['C:\\Users\\BashfaceTheTruncheon\\desktop\\learn_python',
 'C:\\Users\\BashfaceTheTruncheon\\desktop\\learn_python']
139 INFO: checking Analysis
140 INFO: Building Analysis because out00-Analysis.toc is non existent
142 INFO: Initializing module dependency graph...
149 INFO: Initializing module graph hooks...
152 INFO: Analyzing base_library.zip ...
2454 INFO: running Analysis out00-Analysis.toc
2526 WARNING: Can not get binary dependencies for file: c:\users\bashfacethetruncheon\miniconda3\api-ms-win-crt
Traceback (most recent call last):
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 695,
    return _getImports_pe(pth)
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 122,
    dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
2534 WARNING: Can not get binary dependencies for file: c:\users\bashfacethetruncheon\miniconda3\api-ms-win-crt
Traceback (most recent call last):
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 695,
    return _getImports_pe(pth)
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 122,
    dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
2554 WARNING: Can not get binary dependencies for file: c:\users\bashfacethetruncheon\miniconda3\api-ms-win-crt
Traceback (most recent call last):
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 695,
    return _getImports_pe(pth)
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 122,
    dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
2561 WARNING: Can not get binary dependencies for file: c:\users\bashfacethetruncheon\miniconda3\api-ms-win-crt
Traceback (most recent call last):
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 695,
    return _getImports_pe(pth)
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 122,
    dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
2594 WARNING: Can not get binary dependencies for file: c:\users\bashfacethetruncheon\miniconda3\api-ms-win-crt
Traceback (most recent call last):
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 695,
    return _getImports_pe(pth)
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 122,
    dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
2990 WARNING: Can not get binary dependencies for file: c:\users\bashfacethetruncheon\miniconda3\api-ms-win-crt
Traceback (most recent call last):
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 695,
    return _getImports_pe(pth)
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 122,
    dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
3017 WARNING: Can not get binary dependencies for file: c:\users\bashfacethetruncheon\miniconda3\api-ms-win-crt
Traceback (most recent call last):
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 695,
    return _getImports_pe(pth)
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 122,
    dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
3023 WARNING: Can not get binary dependencies for file: c:\users\bashfacethetruncheon\miniconda3\api-ms-win-crt
Traceback (most recent call last):
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 695,
    return _getImports_pe(pth)
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 122,
    dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
3031 WARNING: Can not get binary dependencies for file: c:\users\bashfacethetruncheon\miniconda3\api-ms-win-crt
Traceback (most recent call last):
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 695,
    return _getImports_pe(pth)
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 122,
    dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
3049 WARNING: Can not get binary dependencies for file: c:\users\bashfacethetruncheon\miniconda3\api-ms-win-crt
Traceback (most recent call last):
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 695,
    return _getImports_pe(pth)
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 122,
    dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
3059 WARNING: Can not get binary dependencies for file: c:\users\bashfacethetruncheon\miniconda3\api-ms-win-crt
Traceback (most recent call last):
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 695,
    return _getImports_pe(pth)
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 122,
    dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
3069 WARNING: Can not get binary dependencies for file: c:\users\bashfacethetruncheon\miniconda3\api-ms-win-crt
Traceback (most recent call last):
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 695,
    return _getImports_pe(pth)
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 122,
    dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
3073 INFO: Caching module hooks...
3078 INFO: Analyzing C:\Users\BashfaceTheTruncheon\desktop\learn_python\timetorun.py
3084 INFO: Loading module hooks...
3085 INFO: Loading module hook "hook-xml.py"...
3258 INFO: Loading module hook "hook-pydoc.py"...
3259 INFO: Loading module hook "hook-encodings.py"...
3283 INFO: Looking for ctypes DLLs
3289 INFO: Analyzing run-time hooks ...
3300 INFO: Looking for dynamic libraries
3783 WARNING: Can not get binary dependencies for file: c:\users\bashfacethetruncheon\miniconda3\api-ms-win-crt
Traceback (most recent call last):
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 695,
    return _getImports_pe(pth)
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\depend\bindepend.py", line 122,
    dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
3784 INFO: Looking for eggs
3785 INFO: Using Python library c:\users\bashfacethetruncheon\miniconda3\python35.dll
3787 INFO: Found binding redirects:
[]
3804 INFO: Warnings written to C:\Users\BashfaceTheTruncheon\desktop\learn_python\build\timetorun\warntimetorun
3814 INFO: checking PYZ
3815 INFO: Building PYZ because out00-PYZ.toc is non existent
3815 INFO: Building PYZ (ZlibArchive) C:\Users\BashfaceTheTruncheon\desktop\learn_python\build\timetorun\out00-
4336 INFO: checking PKG
4336 INFO: Building PKG because out00-PKG.toc is non existent
4337 INFO: Building PKG (CArchive) out00-PKG.pkg
Traceback (most recent call last):
  File "c:\users\bashfacethetruncheon\miniconda3\lib\runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\bashfacethetruncheon\miniconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\BashfaceTheTruncheon\Miniconda3\Scripts\pyinstaller.exe\__main__.py", line 9, in <module>
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\__main__.py", line 90, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\__main__.py", line 46, in run_bu
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\building\build_main.py", line 78
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\building\build_main.py", line 73
    exec(text, spec_namespace)
  File "<string>", line 28, in <module>
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\building\api.py", line 398, in _
    strip_binaries=self.strip, upx_binaries=self.upx,
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\building\api.py", line 189, in _
    self.__postinit__()
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\building\datastruct.py", line 17
    self.assemble()
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\building\api.py", line 274, in a
    pylib_name=pylib_name)
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\archive\writers.py", line 329, i
    super(CArchiveWriter, self).__init__(archive_path, logical_toc)
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\archive\writers.py", line 59, in
    self._add_from_table_of_contents(logical_toc)
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\archive\writers.py", line 84, in
    self.add(toc_entry)  # The guts of the archive.
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\archive\writers.py", line 370, i
    code = get_code_object(nm, pathnm)
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\building\utils.py", line 545, in
    co = _load_code(modname, filename)
  File "c:\users\bashfacethetruncheon\miniconda3\lib\site-packages\PyInstaller\building\utils.py", line 521, in
    assert loader and hasattr(loader, 'get_code')
AssertionError

3 个答案:

答案 0 :(得分:5)

在尝试制作我的程序版本4.1时,我遇到了同样的问题。有一些关于&#34;。&#34; 4到1之间正在操作扳手。我重命名了我的文件&#34; Program_V4_1.py&#34;它起作用了。

答案 1 :(得分:2)

当我想用Pyinstaller构建.exe时,我也遇到了同样的错误。

我用这个命令构建它:

pyinstaller.exe --onefile --noconsole --icon=icon.ico appbuilder.py

这给了我以下错误:

(...)python35-32\lib\site-packages\PyInstaller\building\utils.py", line 521, in _load_code

事实证明,当我尝试时,pyinstaller.exe区分大小写:

pyinstaller.exe --onefile --noconsole --icon=icon.ico AppBuilder.py

我得到了理想的结果。 (注意文件名中的大写章程)

<强>结论

您可能想要检查您要转换的脚本的文件名是否完全相同。

答案 2 :(得分:0)

只需在python安装程序中运行修复功能即可。它应该删除丑陋的。

python3.5.1thing

pythonrepair3.5.1thing