PySide - Qt: Could not initialize OLE (error 80010106)

4.3k Views Asked by At

I'm using PySide with Python 2.7.3 x64, and when running my Qt application, I'm noticing the following error show up in the output of Wing IDE.

Qt: Could not initialize OLE (error 80010106)

This doesn't appear to be causing issues until I close the Qt application when I run it outside of Wing. The closed app will throw up a pythonw.exe windows error. I'm assuming the two are related, as it happens on even the most basic of Qt app. But I'm not exactly sure what the deal is. Any ideas would be really appreciated!

3

There are 3 best solutions below

0
Steve On

I know this is old, but I came to the same conclusion as this.myself so I decided to post it as an answer for other people in the future.

The problem for me was that another library was importing the clr module to use some .NET libraries, which was causing these issues when I would later run:

appQT = QtGui.QApplication([])

By initializing Qt at the beginning of the program (even before imports), you guarantee that it will be initialized before clr is imported. You can then slowly move the Qt initialization farther back in the program until you get the error again (if you don't know which library is importing clr).

It's not an ideal solution but it does work for me.

1
David J On

The problem will be to do with Qt calling OleInitialize or CoInitialize on thread that has already been initialized to the MTA apartment model.

Those having issues after importing clr should note that in the .Net world threads are initialized as MTA by default although this can be changed by either calling SetApartmentState or using the STAThreadAttribute.

0
den.run.ai On

This issue is resolved by call to CoInitialize before import clr:

https://github.com/pythonnet/pythonnet/issues/439