mrob95/pyvda

OSError: [WinError -2147221008] CoInitialize has not been called

Closed this issue · 3 comments

CoInitialize() must be added to _get_object in utils.py or else it will throw the above error. This took me a while to figure out, as i kept trying to fix it by calling CoInitialize() from my own script, to no avail.

Hi, thanks for raising this! Couple of quick questions as I haven't run into this before:

  • Are you calling the pyvda routines from a separate (non-main) Python thread?
  • What Python version are you running?

Thanks

I am using it from a Flask endpoint, but I'm pretty sure that's on the main thread.
I'm using Python 3.10.0

Thanks, I can repro this calling from a thread and it looks like other COM libraries initialise within the library, e.g.

https://sourcegraph.com/github.com/xlwings/xlwings/-/blob/xlwings/_xlwindows.py?L245

Will merge your fix and create a release