3

I'm trying to turn my python script into an exe file using pyinstaller but it keeps throwing errors when compiling like:

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

and then when i try to run the exe file it tells me error loading dll:(error code 193)

Thanks.

HackAfro
  • 720
  • 1
  • 12
  • 28

4 Answers4

0

I solved this by removing the --onefile argument and UPX from my folder. After creating the exe I manually downloaded all missing dlls and packaged it. Works like a charm only disadvantage is you have soo many files in the folder.

HackAfro
  • 720
  • 1
  • 12
  • 28
0

Error code 193 means ERROR_BAD_EXE_FORMAT according to MSDN. So your binary is corrupted for some reason.

Taking into account that you have not corrupted it in any way, I can figure some possible reasons for this to have happened:

  1. UPX is ruining your binary when it is compressing/decompressing it. ... OR ...
  2. PyInstaller bootloader is corrupting your files when it decompress the one-file bundle. ... OR...
  3. Both UPX and PyInstaller are working together to make your life harder.

Obviously, this should not be happening (it is a bug), but since it is, you have to workaround this problem. So try these solutions:

  • Run PyInstaller with --noupx argument. This will assure that UPX is not the villain. If so, just stop using it. ... OR...
  • Run PyInstaller without -F/--onefile (or with -D/--onedir argument, note that you can not use both of them at the same time). This will keep files separated as they are supposed to be (when you generate a one-file bundle, PyInstaller bootloader extract all files into a temporary folder).
Diego Queiroz
  • 3,198
  • 1
  • 24
  • 36
0

I use pyinstaller in windows10, the python35.dll will depend on api-ms-win-crt*.dll, so you should use --path add the dll dir.

Install the dll, refer to https://stackoverflow.com/a/33274879/1401057, and search the api-ms-win-crt*.dll copy to a dir /path/api-ms-win-dll/. Pyinstaller add --path /path/api-ms-win-dll/.

Community
  • 1
  • 1
lvshuchengyin
  • 235
  • 1
  • 4
  • 19
0

I got a similar error code (Error loading Python DLL: C:\some\temporary\path\to\python35.dll (error code 193)) after attempting to run an exe generated from a 32-bit version of Python 3.5, after previously building an exe generated from a 64-bit version of Python 3.5 on the same machine.

I think the PyInstaller build process leaves some artifacts behind, meaning that incorrect DLLs are included in the packaged exe file.

To get around this I used the --clean flag when I ran PyInstaller, which generated a working 32-bit exe.

Andrew Borley
  • 1,684
  • 2
  • 11
  • 13