Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: module 'win32ctypes.pywin32.win32api' has no attribute 'error'

Tags:

python

(venv) C:\Users\idanf\PycharmProjects\untitled>pyinstaller -w -F -i "C:\Users\idanf\PycharmProjects\untitled\logo.png" gui.py

In top have the command that I use to create exe. file from py file.

I'm trying to make my gui.py (pyqt5 lib for gui) to exe file and get this error.

How can I fix it or create the exe. file in other way?

I tried to use the cmd and pycharm and both the same problem.

I can provide the code if needed.

if I need to provide more info let me know

80 INFO: PyInstaller: 3.5
81 INFO: Python: 3.7.3
81 INFO: Platform: Windows-10-10.0.18362-SP0
83 INFO: wrote C:\Users\idanf\PycharmProjects\untitled\gui.spec
87 INFO: UPX is not available.
89 INFO: Extending PYTHONPATH with paths
['C:\\Users\\idanf\\PycharmProjects\\untitled',
 'C:\\Users\\idanf\\PycharmProjects\\untitled']
89 INFO: checking Analysis
117 INFO: checking PYZ
135 INFO: checking PKG
144 INFO: Building because C:\Users\idanf\PycharmProjects\untitled\build\gui\gui.exe.manifest changed
144 INFO: Building PKG (CArchive) PKG-00.pkg
463 WARNING: One binary added with two internal names.
464 WARNING: ('libGLESv2.dll',
 'C:\\users\\idanf\\anaconda3\\lib\\site-packages\\PyQt5\\Qt\\bin\\libGLESv2.dll',
 'BINARY')
464 WARNING: was placed previously at
465 WARNING: ('PyQt5\\Qt\\bin\\libGLESv2.dll',
 'C:\\users\\idanf\\anaconda3\\lib\\site-packages\\PyQt5\\Qt\\bin\\libGLESv2.dll',
 'BINARY')
14719 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
14724 INFO: Bootloader c:\users\idanf\pycharmprojects\untitled\venv\lib\site-packages\PyInstaller\bootloader\Windows-64bit\runw.exe
14725 INFO: checking EXE
14725 INFO: Building EXE because EXE-00.toc is non existent
14725 INFO: Building EXE from EXE-00.toc
14730 INFO: Copying icons from C:\Users\idanf\PycharmProjects\untitled\logo.png
Traceback (most recent call last):
  File "c:\users\idanf\pycharmprojects\untitled\venv\lib\site-packages\win32ctypes\pywin32\pywintypes.py", line 35, in pywin32error
    yield
  File "c:\users\idanf\pycharmprojects\untitled\venv\lib\site-packages\win32ctypes\pywin32\win32api.py", line 43, in LoadLibraryEx
    return _dll._LoadLibraryEx(fileName, 0, flags)
  File "c:\users\idanf\pycharmprojects\untitled\venv\lib\site-packages\win32ctypes\core\ctypes\_util.py", line 42, in check_null
    raise make_error(function, function_name)
OSError: [WinError 193] <no description>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\idanf\pycharmprojects\untitled\venv\lib\site-packages\PyInstaller\utils\win32\icon.py", line 231, in CopyIcons
    hsrc = win32api.LoadLibraryEx(srcpath, 0, LOAD_LIBRARY_AS_DATAFILE)
  File "c:\users\idanf\pycharmprojects\untitled\venv\lib\site-packages\win32ctypes\pywin32\win32api.py", line 43, in LoadLibraryEx
    return _dll._LoadLibraryEx(fileName, 0, flags)
  File "C:\Users\idanf\Anaconda3\lib\contextlib.py", line 130, in __exit__
    self.gen.throw(type, value, traceback)
  File "c:\users\idanf\pycharmprojects\untitled\venv\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', '<no description>')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\idanf\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\idanf\Anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\idanf\PycharmProjects\untitled\venv\Scripts\pyinstaller.exe\__main__.py", line 9, in <module>
  File "c:\users\idanf\pycharmprojects\untitled\venv\lib\site-packages\PyInstaller\__main__.py", line 111, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "c:\users\idanf\pycharmprojects\untitled\venv\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "c:\users\idanf\pycharmprojects\untitled\venv\lib\site-packages\PyInstaller\building\build_main.py", line 844, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "c:\users\idanf\pycharmprojects\untitled\venv\lib\site-packages\PyInstaller\building\build_main.py", line 791, in build
    exec(code, spec_namespace)
  File "C:\Users\idanf\PycharmProjects\untitled\gui.spec", line 33, in <module>
    console=False , icon='C:\\Users\\idanf\\PycharmProjects\\untitled\\logo.png')
  File "c:\users\idanf\pycharmprojects\untitled\venv\lib\site-packages\PyInstaller\building\api.py", line 444, in __init__
    self.__postinit__()
  File "c:\users\idanf\pycharmprojects\untitled\venv\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__
    self.assemble()
  File "c:\users\idanf\pycharmprojects\untitled\venv\lib\site-packages\PyInstaller\building\api.py", line 534, in assemble
    icon.CopyIcons(tmpnm, self.icon)
  File "c:\users\idanf\pycharmprojects\untitled\venv\lib\site-packages\PyInstaller\utils\win32\icon.py", line 232, in CopyIcons
    except win32api.error as W32E:
AttributeError: module 'win32ctypes.pywin32.win32api' has no attribute 'error'
like image 975
idan ovadia Avatar asked Oct 25 '19 11:10

idan ovadia


2 Answers

I am new to python. But, I had the same error. It worked for me when I tried these things.

  1. Try using .ico file for the app icon
  2. Try changing the directory of that .ico file to your script directory and run it again.
like image 59
Silver Avatar answered Oct 30 '22 10:10

Silver


as soon as i used an .ico it worked for me.

i used this code to convert any type to .ico :

from PIL import Image
from tkinter import filedialog, Tk
from getpass import getuser

# any path possible
def convert(path):
    print("converting")
    #path = str(path)
    print(path)
    img = Image.open(path)
    #where is the '.' ?
    extension = path.find('.')
    img.save(path[:extension]+".ico")


# get a path name for a file
gui = Tk()
#gui.iconbitmap('C:/Users/Severin/OneDrive/Desktop/icon.ico')
user = getuser()

# Get the file
filepath = filedialog.askopenfilename()
# Split the filepath to get the directory
#directory = os.path.split(file)[0]
convert(filepath)

like image 23
Severin Spörri Avatar answered Oct 30 '22 12:10

Severin Spörri