1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] win32com.client Dispatch can't find Crystal Reports

Discussão em 'Python' iniciado por Stack, Setembro 17, 2025.

  1. Stack

    Stack Membro Participativo

    I'm making a React app with a Python/Flask back end. The user enters some information, this is sent to a python script that enters it into a crystal report, the report is generated & saved as a PDF on the server, and then the PDF is sent back to the user.

    This exact script has worked on a different machine with an HTML front end, so the code itself should be solid. When I try to use it with my app, it gets stuck on this line:

    app2=Dispatch('CrystalRuntime.Application')


    And I get this error:

    pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)


    My understanding is that this means that Python thinks Crystal Reports isn't installed. It definitely is installed. I've tried uninstalling and reinstalling a few different versions to see if that resolved the issue, but it hasn't. I've made sure that both Python and Crystal Reports are both 64 bit. Why can't they talk to each other?

    More of my script:

    import os
    import sys
    import pythoncom

    pythoncom.CoInitialize ()

    from win32com.client import Dispatch
    import win32com.client

    import pyodbc
    import pandas as pd

    def Generate_Final_Report(self,Batch, PerDiem):

    pythoncom.CoInitialize()
    app2=Dispatch('CrystalRuntime.Application') #it never gets past here

    Continue reading...

Compartilhe esta Página