4

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
  • I get the same error, want to know how to get rid of it. It looks like nothing to do with Wing; I'm just using PySide + Python 2.7.3 Commented Jan 9, 2014 at 21:55
  • 1
    I take that back; I'm also using .NET. That error code is a Windows thing which looks like something to do with threading: support.microsoft.com/kb/824480 Commented Jan 9, 2014 at 21:58
  • 2
    I get that error as soon as I import the clr module (for using .NET). My application freezes when I want to display a folder dialog (QtGui.QFileDialog.getExistingDirectory()), when I imported clr anytime before. In a project of a colleague drag-and-drop stops working as soon he imports clr. It must be a windows thing. ''But:'' It seems I solved the issue by placing the import clr later, just before using the .NET object. Then the FolderDialog works - and it also works if it is called multiple times (and therfor after import clr too).... :-/ Order of initializing stuff might be important... Commented Apr 25, 2014 at 15:32

3 Answers 3

6

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, adding [System::STAThread] just before the main function did the job.
3

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.

Comments

1

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.