我正尝试编写一个使用QBFC和win32com库访问本地服务器上的Quickbooks Pro Desktop 2016的Python脚本。
它指出win32com使Python能够与COM通讯。我不熟悉COM对象。
我已经点击了此链接,该链接似乎可以执行我尝试的操作。 http://cheesehead-techblog.blogspot.com/2011/01/how-to-get-python-to-talk-to-quickbooks.html
我已经安装了Quickbooks SDK,并将QBFC10.dll下载到了运行Windows 2012 Server R2的服务器上。我正在使用Python 3.5 64位。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
</head>
<body>
<img src="test.jpg" width="100%" height="100%" id="bg" />
<div id="contents">
<a href="" class="status">On</a>
</div>
</body>
</html>
我已经阅读到在32位win32com上运行64位Python会出现问题。但是,我的主要问题是错误pywintypes.com错误:(-2147221164,'Class notregistered',None,None)。
Quickbooks SDK是否需要以某种方式注册COM对象? 我错过了一步吗?
我的代码在下面列出:
Traceback (most recent call last):
File "C:\Python35\lib\site-packages\win32com\client\dynamic.py", line 89, in
_GetGoodDispatch
IDispatch = pythoncom.connect(IDispatch)
pywintypes.com_error: (-2147221021, 'Operation unavailable', None, None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\TylerAdmin\Desktop\Python\QBTest.py", line 28, in <module>
s,t=connect(qb_path, name)
File "C:\Users\TylerAdmin\Desktop\Python\QBTest.py", line 15, in connect
sessionManager = win32com.client.Dispatch("QBXMLRP2.RequestProcessor")
File "C:\Python35\lib\site-packages\win32com\client\__init__.py", line 95,
in Dispatch
dispatch, userName =
dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File "C:\Python35\lib\site-packages\win32com\client\dynamic.py", line 114,
in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Python35\lib\site-packages\win32com\client\dynamic.py", line 91, in
_GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
pythoncom.IID_IDispatch)
pywintypes.com_error: (-2147221164, 'Class not registered', None, None)