环境:
window7 64bit
python 3.5
pyinstaller 3.2
用pyinstaller 将python文件打包成exe文件的过程中,出现了如下的错误
C:\Users\caoxin\PyInstaller-3.2>python pyinstaller.py --console --onefile main5.
py
249 INFO: PyInstaller: 3.2
249 INFO: Python: 3.5.0
250 INFO: Platform: Windows-7-6.1.7601-SP1
252 INFO: wrote C:\Users\caoxin\PyInstaller-3.2\main5\main5.spec
253 INFO: UPX is not available.
256 INFO: Extending PYTHONPATH with paths
['C:\\Users\\caoxin\\PyInstaller-3.2',
'C:\\Users\\caoxin\\PyInstaller-3.2\\main5']
256 INFO: checking Analysis
256 INFO: Building Analysis because out00-Analysis.toc is non existent
258 INFO: Initializing module dependency graph...
259 INFO: Initializing module graph hooks...
262 INFO: Analyzing base_library.zip ...
2670 INFO: running Analysis out00-Analysis.toc
2746 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api-
ms-win-crt-runtime-l1-1-0.dll
Traceback (most recent call last):
File "C:\Users\caoxin\PyInstaller-3.2\PyInstaller\depend\bindepend.py", line 6
95, in getImports
return _getImports_pe(pth)
File "C:\Users\caoxin\PyInstaller-3.2\PyInstaller\depend\bindepend.py", line 1
22, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
2815 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api-
ms-win-crt-stdio-l1-1-0.dll
Traceback (most recent call last):
File "C:\Users\caoxin\PyInstaller-3.2\PyInstaller\depend\bindepend.py", line 6
95, in getImports
return _getImports_pe(pth)
File "C:\Users\caoxin\PyInstaller-3.2\PyInstaller\depend\bindepend.py", line 1
22, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
2819 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api-
ms-win-crt-heap-l1-1-0.dll
Traceback (most recent call last):
File "C:\Users\caoxin\PyInstaller-3.2\PyInstaller\depend\bindepend.py", line 6
95, in getImports
return _getImports_pe(pth)
File "C:\Users\caoxin\PyInstaller-3.2\PyInstaller\depend\bindepend.py", line 1
22, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
2829 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api-
ms-win-crt-locale-l1-1-0.dll
Traceback (most recent call last):
File "C:\Users\caoxin\PyInstaller-3.2\PyInstaller\depend\bindepend.py", line 6
95, in getImports
return _getImports_pe(pth)
File "C:\Users\caoxin\PyInstaller-3.2\PyInstaller\depend\bindepend.py", line 1
22, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
2864 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api-
ms-win-crt-math-l1-1-0.dll
Traceback (most recent call last):
File "C:\Users\caoxin\PyInstaller-3.2\PyInstaller\depend\bindepend.py", line 6
95, in getImports
return _getImports_pe(pth)
File "C:\Users\caoxin\PyInstaller-3.2\PyInstaller\depend\bindepend.py", line 1
22, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
3276 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api-
ms-win-crt-string-l1-1-0.dll
Traceback (most recent call last):
File "C:\Users\caoxin\PyInstaller-3.2\PyInstaller\depend\bindepend.py", line 6
95, in getImports
return _getImports_pe(pth)
File "C:\Users\caoxin\PyInstaller-3.2\PyInstaller\depend\bindepend.py", line 1
22, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
3292 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api-
ms-win-crt-convert-l1-1-0.dll
Traceback (most recent call last):
File "C:\Users\caoxin\PyInstaller-3.2\PyInstaller\depend\bindepend.py", line 6
95, in getImports
return _getImports_pe(pth)
File "C:\Users\caoxin\PyInstaller-3.2\PyInstaller\depend\bindepend.py", line 1
22, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
3298 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api-
ms-win-crt-conio-l1-1-0.dll
Traceback (most recent call last):
File "C:\Users\caoxin\PyInstaller-3.2\PyInstaller\depend\bindepend.py", line 6
95, in getImports
return _getImports_pe(pth)
File "C:\Users\caoxin\PyInstaller-3.2\PyInstaller\depend\bindepend.py", line 1
22, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
3305 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api-
ms-win-crt-process-l1-1-0.dll
Traceback (most recent call last):
File "C:\Users\caoxin\PyInstaller-3.2\PyInstaller\depend\bindepend.py", line 6
95, in getImports
return _getImports_pe(pth)
File "C:\Users\caoxin\PyInstaller-3.2\PyInstaller\depend\bindepend.py", line 1
22, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
3315 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api-
ms-win-crt-time-l1-1-0.dll
Traceback (most recent call last):
File "C:\Users\caoxin\PyInstaller-3.2\PyInstaller\depend\bindepend.py", line 6
95, in getImports
return _getImports_pe(pth)
File "C:\Users\caoxin\PyInstaller-3.2\PyInstaller\depend\bindepend.py", line 1
22, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
3319 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api-
ms-win-crt-environment-l1-1-0.dll
Traceback (most recent call last):
File "C:\Users\caoxin\PyInstaller-3.2\PyInstaller\depend\bindepend.py", line 6
95, in getImports
return _getImports_pe(pth)
File "C:\Users\caoxin\PyInstaller-3.2\PyInstaller\depend\bindepend.py", line 1
22, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
3331 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api-
ms-win-crt-filesystem-l1-1-0.dll
Traceback (most recent call last):
File "C:\Users\caoxin\PyInstaller-3.2\PyInstaller\depend\bindepend.py", line 6
95, in getImports
return _getImports_pe(pth)
File "C:\Users\caoxin\PyInstaller-3.2\PyInstaller\depend\bindepend.py", line 1
22, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
3332 INFO: Caching module hooks...
3337 INFO: Analyzing C:\Users\caoxin\PyInstaller-3.2\main5.py
3374 INFO: Loading module hooks...
3375 INFO: Loading module hook "hook-encodings.py"...
3384 INFO: Loading module hook "hook-pydoc.py"...
3384 INFO: Loading module hook "hook-xml.py"...
3602 INFO: Looking for ctypes DLLs
3602 INFO: Analyzing run-time hooks ...
3612 INFO: Looking for dynamic libraries
4173 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api-
ms-win-crt-utility-l1-1-0.dll
Traceback (most recent call last):
File "C:\Users\caoxin\PyInstaller-3.2\PyInstaller\depend\bindepend.py", line 6
95, in getImports
return _getImports_pe(pth)
File "C:\Users\caoxin\PyInstaller-3.2\PyInstaller\depend\bindepend.py", line 1
22, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
4332 INFO: Looking for eggs
4332 INFO: Using Python library C:\Users\caoxin\AppData\Local\Programs\Python\Py
thon35\python35.dll
4334 INFO: Found binding redirects:
[]
4342 INFO: Warnings written to C:\Users\caoxin\PyInstaller-3.2\main5\build\main5
\warnmain5.txt
4355 INFO: checking PYZ
4355 INFO: Building PYZ because out00-PYZ.toc is non existent
4357 INFO: Building PYZ (ZlibArchive) C:\Users\caoxin\PyInstaller-3.2\main5\buil
d\main5\out00-PYZ.pyz
4900 INFO: checking PKG
4901 INFO: Building PKG because out00-PKG.toc is non existent
4901 INFO: Building PKG (CArchive) out00-PKG.pkg
6788 INFO: Bootloader C:\Users\caoxin\PyInstaller-3.2\PyInstaller\bootloader\Win
dows-64bit\run.exe
6789 INFO: checking EXE
6789 INFO: Building EXE because out00-EXE.toc is non existent
6789 INFO: Building EXE from out00-EXE.toc
6789 INFO: Appending archive to EXE C:\Users\caoxin\PyInstaller-3.2\main5\dist\m
ain5.exe
通过google,找到最终的解决方案,原因是pyinstaller 3.2有bug,目前开发版本的pyinstaller解决了此bug,所以用pyinstaller-develop版本就可以将此问题解决。
即直接执行:
pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip
然后解压该安装包,进入解压的文件夹内执行
python pyinstaller.py --console --onefile main5.py
问题得到修复。
另外值得注意的一点,在Win7 64位的操作系统中,也要装python3.5 32位的安装包。具体原因如下:
参考网址:
WARNING: Can not get binary dependencies for file
Why isn't pyinstaller making me an .exe file?