Py2exe and the missing icon

I am using pyqt, the icon is being added.

icon.addPixmap(QtGui.QPixmap(_fromUtf8("favicon.ico")), QtGui.QIcon.Normal, QtGui.QIcon.Off) MainWindow.setWindowIcon(icon) 

In setup.py for py2exe, I am trying to add an icon to resources.

 from distutils.core import setup import py2exe setup( console=[{ "script" : "manage.py", "icon_resources": [(1, "favicon.ico")] }], options={ "py2exe" : {"includes" : ["sip",]} } ) 

When I run my program from the IDE as a python script, I see my icon. When I create an exe program with py2exe, my program works well, but the icon disappears.

+4
source share
1 answer

The problem is that py2exe does not include the qt icon reader plugin. Added parameter Data_files.

 from distutils.core import setup import py2exe setup( options={ "py2exe" : {"includes" : ["sip",]} }, data_files = [ ('imageformats', [ r'C:\programs\Python271\Lib\site-packages\PyQt4\plugins\imageformats\qico4.dll' ])], console=[{ "script" : "manage.py" }] ) 
+6
source

Source: https://habr.com/ru/post/1484276/


All Articles