0

I have a strange error in my Python Flask app running on VS Code in Windows 10. The app runs as intended for the first time, however whenever I run the app for a second time, I get this error: "CoInitialize has not been called".

I've tried using pythoncom but this doesn't seem to have an effect. From searching it seems like pythoncom is for win32 (I'm using Win64 and 64 bit python) and when I tried to install pywin32 and pypiwin32 it said it was already installed on my device.

My app is an ocr/tts application built in flask. Here are my imports and the pythoncom line:

import os
from flask import Flask, render_template, request, flash, redirect, url_for
from werkzeug.utils import secure_filename
import pytesseract as tess
import pyttsx3
import cv2
import pythoncom

pythoncom.CoInitialize()

I would appreciate any help from someone who might know what the problem is or what to try next.

Leon
  • 1
  • 1
  • This seems to be an error with the pyttsx3 module. I have changed the title accordingly. – Leon Aug 15 '20 at 20:48
  • Interesting. As far as I know you can use pythoncom on 64-bit. The coinitialize should be called when a thread uses COM objects. – Borut Flis Apr 12 '21 at 11:27
  • 1
    @Leon did you get any solution for that? I'm also getting the same errror while using python's `comtypes` module to convert docx to pdf. – ninjacode Dec 03 '21 at 05:03

0 Answers0