PyInstaller 断言错误 - 以前工作正常,现在不行了
PyInstaller Assertion Error - used to work fine, now it doesn't
我正在尝试使用 PyInstaller。我过去曾在同一个系统上多次使用它,并且能够成功地将我的程序打包为 .exe 文件,但现在有些东西不起作用,我不确定发生了什么变化。
它给了我一些错误(“TypeError: a bytes-like object is required, not 'str'
”出现了好几次),但我对此很陌生,我不明白它们的意思或如何处理它们。所以我打算 post 整个该死的输出,希望有人能告诉我如何解决这个问题。
无论程序使用什么模块,我尝试使用 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
只是 运行 python 安装程序中的修复功能。它应该去除丑陋的东西。
我在尝试制作程序的 4.1 版时遇到了同样的问题。关于“。”有一些东西。在 4 和 1 之间,这是在操作中抛出一个扳手。我重命名了我的文件 "Program_V4_1.py" 并且它起作用了。
当我想用 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
我得到了想要的结果。 (注意文件名中的大写字符)
结论:
您可能需要检查您正在转换的脚本的文件名是否完全相同。
我正在尝试使用 PyInstaller。我过去曾在同一个系统上多次使用它,并且能够成功地将我的程序打包为 .exe 文件,但现在有些东西不起作用,我不确定发生了什么变化。
它给了我一些错误(“TypeError: a bytes-like object is required, not 'str'
”出现了好几次),但我对此很陌生,我不明白它们的意思或如何处理它们。所以我打算 post 整个该死的输出,希望有人能告诉我如何解决这个问题。
无论程序使用什么模块,我尝试使用 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
只是 运行 python 安装程序中的修复功能。它应该去除丑陋的东西。
我在尝试制作程序的 4.1 版时遇到了同样的问题。关于“。”有一些东西。在 4 和 1 之间,这是在操作中抛出一个扳手。我重命名了我的文件 "Program_V4_1.py" 并且它起作用了。
当我想用 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
我得到了想要的结果。 (注意文件名中的大写字符)
结论:
您可能需要检查您正在转换的脚本的文件名是否完全相同。