0

I'm trying to use PyInstaller. I've used it several times in the past on this same system and been able to successfully package my programs to .exe files, but now something isn't working and I'm not sure what changed.

It gives me some errors ("TypeError: a bytes-like object is required, not 'str'" occurs several times), but I'm so new at this I don't understand what they mean or what to do about them. So I'm just going to post the whole damn output in the hopes that someone can tell me how to fix this.

This same error happens for every program I try to package using PyInstaller, regardless of what modules the program uses. Even simple test programs that don't import anything are giving me this same error. It also happens whether I use the --onefile command or leave it out.

Here's the whole ugly thing:

    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
1
  • Hah! Thanks. I thought about editing all my personal stuff out, but it seemed like too much effort. Jun 21, 2016 at 18:27

3 Answers 3

6

I had this same problem when trying to make a version 4.1 of my program. There is something about the "." between 4 and 1 that is throwing a wrench in the operation. I renamed my file "Program_V4_1.py" and it worked.

1
  • 1
    I encountered the same issue, with PyInstaller 3.2: I had a filename in the format x.y.py, and it choked on the extra period. Upon renaming it to something with a single period before the file extension, it worked like a charm. Nov 1, 2016 at 22:40
2

I also got the same error when i wanted to build an .exe with Pyinstaller.

I used this command to build it:

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

That gave me the folowing error:

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

It turned out that pyinstaller.exe is case sensitive, when i tried:

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

I got the desired result. (Notice the uppercase charters in the filename)

Conclusion:

You may want to check if the file name the script you're converting is exactly the same.

1
  • this is actually what my issue was. Doesn't appear the other parts of the path need to follow case but the .py file name must.
    – Sludge
    Sep 25, 2016 at 5:34
0

Just run the repair function in on the python installer. It should remove the ugly.

python3.5.1thing

pythonrepair3.5.1thing

2
  • I ran the repair tool, and I'm still getting the exact same output when I try to use PyInstaller. I have, in the past, tried to uninstall and reinstall Python to fix a different issue, and now I'm wondering if I broke it even more. Is there a way to completely remove old files and settings to start with a totally fresh Python installation? Jun 21, 2016 at 20:02
  • Other than using the repair function, contact python.org's email and tell them because I'm not sure how ****** you are.
    – theshover
    Jun 23, 2016 at 1:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.