在我启动exe时加载Python dll:python35.dll(错误代码193)时出错

时间:2016-08-08 07:20:08

标签: python python-3.x dll pyinstaller

我正在尝试使用pyinstaller将我的python脚本转换为exe文件,但在编译时会不断抛出错误:

C:\Users\Afro\Desktop\getSERIES>pyinstaller --onedir --onefile --windowed get.py
615 INFO: PyInstaller: 3.2
615 INFO: Python: 3.5.1
630 INFO: Platform: Windows-10-10.0.10586-SP0
630 INFO: wrote C:\Users\Afro\Desktop\getSERIES\get.spec
762 INFO: UPX is available.
762 INFO: Extending PYTHONPATH with paths
['C:\\Users\\Afro\\Desktop\\getSERIES', 'C:\\Users\\Afro\\Desktop\\getSERIES']
781 INFO: checking Analysis
783 INFO: Building Analysis because out00-Analysis.toc is non existent
783 INFO: Initializing module dependency graph...
783 INFO: Initializing module graph hooks...
798 INFO: Analyzing base_library.zip ...
16731 INFO: running Analysis out00-Analysis.toc
17399 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\Afro\AppData\Local\Programs\Python\Python35\lib\site-packages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 695, in getImports
return _getImports_pe(pth)
File "C:\Users\Afro\AppData\Local\Programs\Python\Python35\lib\site-packages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 122, in _getImports_pe
 dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
17546 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\Afro\AppData\Local\Programs\Python\Python35\lib\site-packages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 695, in getImports
return _getImports_pe(pth)
File "C:\Users\Afro\AppData\Local\Programs\Python\Python35\lib\site-packages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 122, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
17662 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\Afro\AppData\Local\Programs\Python\Python35\lib\site-packages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 695, in getImports
return _getImports_pe(pth)
File "C:\Users\Afro\AppData\Local\Programs\Python\Python35\lib\site-packages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 122, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
17715 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\Afro\AppData\Local\Programs\Python\Python35\lib\site-packages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 695, in getImports
return _getImports_pe(pth)
File "C:\Users\Afro\AppData\Local\Programs\Python\Python35\lib\site-packages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 122, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
19912 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\Afro\AppData\Local\Programs\Python\Python35\lib\site-packages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 695, in getImports
return _getImports_pe(pth)
File "C:\Users\Afro\AppData\Local\Programs\Python\Python35\lib\site-packages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 122, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
20050 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\Afro\AppData\Local\Programs\Python\Python35\lib\site-packages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 695, in getImports
return _getImports_pe(pth)
File "C:\Users\Afro\AppData\Local\Programs\Python\Python35\lib\site-packages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 122, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
20182 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\Afro\AppData\Local\Programs\Python\Python35\lib\site-packages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 695, in getImports
return _getImports_pe(pth)
File "C:\Users\Afro\AppData\Local\Programs\Python\Python35\lib\site-packages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 122, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
20266 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\Afro\AppData\Local\Programs\Python\Python35\lib\site-packages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 695, in getImports
return _getImports_pe(pth)
File "C:\Users\Afro\AppData\Local\Programs\Python\Python35\lib\site-packages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 122, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
20366 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\Afro\AppData\Local\Programs\Python\Python35\lib\site-packages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 695, in getImports
return _getImports_pe(pth)
File "C:\Users\Afro\AppData\Local\Programs\Python\Python35\lib\site-packages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 122, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
20434 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\Afro\AppData\Local\Programs\Python\Python35\lib\site-packages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 695, in getImports
return _getImports_pe(pth)
File "C:\Users\Afro\AppData\Local\Programs\Python\Python35\lib\site-packages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 122, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
20497 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\Afro\AppData\Local\Programs\Python\Python35\lib\site-packages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 695, in getImports
return _getImports_pe(pth)
File "C:\Users\Afro\AppData\Local\Programs\Python\Python35\lib\site-packages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 122, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
20566 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\Afro\AppData\Local\Programs\Python\Python35\lib\site-packages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 695, in getImports
return _getImports_pe(pth)
File "C:\Users\Afro\AppData\Local\Programs\Python\Python35\lib\site-packages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 122, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
20613 INFO: Caching module hooks...
20634 INFO: Analyzing C:\Users\Afro\Desktop\getSERIES\get.py
40554 INFO: Loading module hooks...
41855 INFO: Loading module hook "hook-xml.dom.domreg.py"...
41870 INFO: Loading module hook "hook-lxml.etree.py"...
41955 INFO: Loading module hook "hook-xml.py"...
41971 INFO: Loading module hook "hook-requests.py"...
41992 INFO: Loading module hook "hook-selenium.py"...
42039 INFO: Loading module hook "hook-cryptography.py"...
42171 INFO: Loading module hook "hook-pydoc.py"...
42208 INFO: Loading module hook "hook-_tkinter.py"...
43270 INFO: checking Tree
43270 INFO: Building Tree because out00-Tree.toc is non existent
43270 INFO: Building Tree out00-Tree.toc
43691 INFO: checking Tree
43693 INFO: Building Tree because out01-Tree.toc is non existent
43693 INFO: Building Tree out01-Tree.toc
43771 INFO: Loading module hook "hook-encodings.py"...
44109 INFO: Analyzing run-time hooks ...
44140 INFO: Including run-time hook 'pyi_rth__tkinter.py'
44371 INFO: Looking for dynamic libraries
50077 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\Afro\AppData\Local\Programs\Python\Python35\lib\site-packages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 695, in getImports
return _getImports_pe(pth)
File "C:\Users\Afro\AppData\Local\Programs\Python\Python35\lib\site-packages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 122, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
53503 INFO: Looking for eggs
53520 INFO: Using Python library C:\Users\Afro\AppData\Local\Programs\Python\Python35\python35.dll
53524 INFO: Found binding redirects:
[]
53587 INFO: Warnings written to C:\Users\Afro\Desktop\getSERIES\build\get\warnget.txt
54056 INFO: checking PYZ
54072 INFO: Building PYZ because out00-PYZ.toc is non existent
54072 INFO: Building PYZ (ZlibArchive) C:\Users\Afro\Desktop\getSERIES\build\get\out00-PYZ.pyz
59021 INFO: checking PKG
59025 INFO: Building PKG because out00-PKG.toc is non existent
59031 INFO: Building PKG (CArchive) out00-PKG.pkg
89878 INFO: Bootloader C:\Users\Afro\AppData\Local\Programs\Python\Python35\lib\site-packages\pyinstaller-3.2-py3.5.egg\PyInstaller\bootloader\Windows-  64bit\runw.exe
89878 INFO: checking EXE
89893 INFO: Building EXE because out00-EXE.toc is non existent
89893 INFO: Building EXE from out00-EXE.toc

89893 INFO: Appending archive to EXE C:\Users\Afro\Desktop\getSERIES\dist\get.exe

然后当我尝试运行exe文件时它告诉我加载DLL的错误:(错误代码193)

感谢。

4 个答案:

答案 0 :(得分:0)

我通过从我的文件夹中删除--onefile参数和UPX来解决这个问题。创建exe后,我手动下载了所有丢失的dll并将其打包。像魅力唯一的缺点是你在文件夹中有很多文件。

答案 1 :(得分:0)

根据{{​​3}},

错误代码193 表示 ERROR_BAD_EXE_FORMAT 。所以你的二进制文件由于某种原因而被破坏了。

考虑到你没有以任何方式破坏它,我可以找出一些可能的原因:

  1. UPX正在压缩/解压缩二进制文件。 ......或......
  2. PyInstaller引导加载程序在解压缩单文件包时会损坏您的文件。 ......或......
  3. UPX和PyInstaller正在共同努力,让你的生活更加艰难。
  4. 显然,这不应该发生(这是一个错误),但既然如此,你必须解决这个问题。所以试试这些解决方案:

    • 使用--noupx参数运行PyInstaller。这将确保UPX不是恶棍。如果是这样,请停止使用它。 ......或......
    • 运行PyInstaller而不使用-F/--onefile(或使用-D/--onedir参数,请注意您不能同时使用这两个参数)。这将使文件保持原样分离(当您生成单文件包时,MSDN)。

答案 2 :(得分:0)

我在windows10中使用pyinstaller,python35.dll将依赖于api-ms-win-crt * .dll,所以你应该使用--path添加dll目录。

安装dll,参考https://stackoverflow.com/a/33274879/1401057,并将api-ms-win-crt * .dll副本搜索到dir / path / api-ms-win-dll /。 Pyinstaller添加--path / path / api-ms-win-dll /.

答案 3 :(得分:0)

在尝试运行从32位版本的Python 3.5生成的exe之后,我得到了类似的错误代码(Error loading Python DLL: C:\some\temporary\path\to\python35.dll (error code 193)),之前构建了一个从64位版本的Python 3.5生成的exe文件同一台机器。

我认为PyInstaller构建过程会留下一些工件,这意味着打包的exe文件中包含了不正确的DLL。

为了解决这个问题,我在运行PyInstaller时使用了--clean标志,它生成了一个可正常运行的32位exe文件。