Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Windows exe build by providing icon in ICO format #16

Merged
merged 1 commit into from
Jun 24, 2021

Conversation

mrolappe-o21
Copy link
Contributor

Building Windows exe (package.sh -w) currently fails with following error that is caused by the app icon format. This PR fixes the problem by providing the app icon in ICO format.

Traceback (most recent call last):
  File "c:\Python37\lib\site-packages\win32ctypes\pywin32\pywintypes.py", line 35, in pywin32error
    yield
  File "c:\Python37\lib\site-packages\win32ctypes\pywin32\win32api.py", line 43, in LoadLibraryEx
    return _dll._LoadLibraryEx(fileName, 0, flags)
  File "c:\Python37\lib\site-packages\win32ctypes\core\ctypes\_util.py", line 42, in check_null
    raise make_error(function, function_name)
OSError: [WinError 193] Bad EXE format for %1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Python37\lib\site-packages\PyInstaller\utils\win32\icon.py", line 233, in CopyIcons
    hsrc = win32api.LoadLibraryEx(srcpath, 0, LOAD_LIBRARY_AS_DATAFILE)
  File "c:\Python37\lib\site-packages\win32ctypes\pywin32\win32api.py", line 43, in LoadLibraryEx
    return _dll._LoadLibraryEx(fileName, 0, flags)
  File "c:\Python37\lib\contextlib.py", line 130, in __exit__
    self.gen.throw(type, value, traceback)
  File "c:\Python37\lib\site-packages\win32ctypes\pywin32\pywintypes.py", line 37, in pywin32error
    raise error(exception.winerror, exception.function, exception.strerror)
win32ctypes.pywin32.pywintypes.error: (193, 'LoadLibraryExW', 'Bad EXE format for %1.')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Python37\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
  File "c:\Python37\lib\site-packages\PyInstaller\__main__.py", line 114, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "c:\Python37\lib\site-packages\PyInstaller\__main__.py", line 65, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "c:\Python37\lib\site-packages\PyInstaller\building\build_main.py", line 720, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "c:\Python37\lib\site-packages\PyInstaller\building\build_main.py", line 667, in build
    exec(code, spec_namespace)
  File "./logsmith.spec", line 69, in <module>
    icon='./app/assets/app_icon.png')
  File "c:\Python37\lib\site-packages\PyInstaller\building\api.py", line 446, in __init__
    self.__postinit__()
  File "c:\Python37\lib\site-packages\PyInstaller\building\datastruct.py", line 160, in __postinit__
    self.assemble()
  File "c:\Python37\lib\site-packages\PyInstaller\building\api.py", line 540, in assemble
    icon.CopyIcons(tmpnm, self.icon)
  File "c:\Python37\lib\site-packages\PyInstaller\utils\win32\icon.py", line 234, in CopyIcons
    except win32api.error as W32E:
AttributeError: module 'win32ctypes.pywin32.win32api' has no attribute 'error'

@stephanrauh0000
Copy link

The modified version compiles and work flawlessly on my Windows machine. Thanks, @mrolappe-o21!

Maybe we should mention in the READ.me how to compile the library. In a nutshell: if you're using Windows, you need a Linux installation in your WSL, and - like mentioned above - it's compiled using the command package.sh -w.

@redvox redvox merged commit b706b4b into otto-de:master Jun 24, 2021
@redvox
Copy link
Collaborator

redvox commented Jun 24, 2021

Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants