OSError: [Errno 22] Invalid argument - when trying to add an icon

36 views
Skip to first unread message

P S Solanki

unread,
Dec 15, 2020, 3:58:55 AM12/15/20
to PyInstaller
Hello all, 
I have used pyinstaller to create executable for that very same script without an icon file, and it worked amazingly. This time I have an icon file to add. 
it gives me the above said error. The full error traceback and other logging info is HERE.

My spec file content is THIS. I felt like this is an issue with the path, but neither of relative or absolute paths (with or without the **r** of raw string to escape literal backslashes).

The icon file was a png originally. I saved it as ico using paint (which I've done in the past). Maybe that's what's causing the issue.

But I'm not sure. Any help or suggestion is appreciated. If you need any additional info, let me know : )

Thank You :)

bwoodsend

unread,
Dec 15, 2020, 10:56:53 AM12/15/20
to PyInstaller

Hmm, don’t see anything obvious. It looks like you’re doing it correctly. That corner of PyInstaller uses the Windows API so it’s a) very fragile and b) very cryptic if it goes wrong (as you can see). If you run os.startfile(r'D:\pssolanki\projects\client\smartStacks\icon.ico') does it open OK? That would confirm if this is an issue with the path. Failing that maybe try a different converter - although that’s a somewhat unhopeful suggestion.

P S Solanki

unread,
Dec 16, 2020, 4:25:59 AM12/16/20
to PyInstaller
Hey bwoodsend,
Appreciate your response,
however I was able to solve the issue by using an online ico convertor. Turned out that paint could not convert the image to ICO correctly (which it has done for me in the past but I was using cx_Freeze at that time). However the ico file was opening up just the same in the Photos app. 
Reply all
Reply to author
Forward
0 new messages