"Cannot read file" error when loading an .svg file with PyQt4

293 views Asked by At

I'm having troubles using a .svg icon for my windows icon. From what I have read this is due to a bad installation of the PyQt4 plugins, but I am confused on how to fix it. When I try to load the image

self.setWindowIcon(QtGui.QIcon("File-View-front.svg"))

Here is the error message I get:

Cannot read file 'C:/Users/user/PycharmProjects/proj1/File-
View-front.svg', because:  (line 2)

I tried printing the supported image formats with

for imageType in QtGui.QImageReader.supportedImageFormats():
    print(imageType)

Which outputs:

b'bmp'
b'pbm'
b'pgm'
b'png'
b'ppm'
b'xbm'
b'xpm'

So I am missing formats... If I add the correct plugin path with

QtCore.QCoreApplication.addLibraryPath('C:/ProgramData/Anaconda3/Lib/site-packages/PyQt4/plugins')

(which if I understand correctly I could also do using conf.py, but I could not get that to work either)

I do get every format (including b'svg') using QtGui.QImageReader.supportedImageFormats(), but the error remains. I am using Anaconda 4.3.1 and I installed PyQt4 with the wheel file I got here.

0

There are 0 answers