If my problem description is very simple, sorry.
But I found the reason: the startup permissions of sap and python are not the same.
For example, both of these should be run with administrator rights, or run with ordinary user rights.
https://answers.sap.com/questions/13472630/errorcode-2147221020-python-scripts-connect-sap.html
I also encountered this problem recently.
The startup permissions of sap and python are not the same. For example, both of these should be run with administrator rights, or run with ordinary user rights.
I do not guarantee that this method will solve your problem, but you can try
https://stackoverflow.com/questions/61429270/error-with-win32com-client-getobject-when-connecting-to-sap-gui