TypeError: This COM object can not automate the makepy process - please run makepy manually for this object
TypeError: This COM object can not automate the makepy process - please run makepy manually for this object
这是什么错误?
回溯错误
C:\Users\DELL\PycharmProjects\MyNew\venv\Scripts\python.exe
C:/Users/DELL/PycharmProjects/MyNew/agaaaaain.py
Traceback (most recent call last):
File "C:\Users\DELL\PycharmProjects\MyNew\venv\lib\site-
packages\win32com\client\gencache.py", line 530, in EnsureDispatch
ti = disp._oleobj_.GetTypeInfo()
pywintypes.com_error: (-2147418111, 'Call was rejected by callee.', None,
None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/DELL/PycharmProjects/MyNew/agaaaaain.py", line 3, in
<module>
excel = win32.gencache.EnsureDispatch('Excel.Application')
File "C:\Users\DELL\PycharmProjects\MyNew\venv\lib\site-
packages\win32com\client\gencache.py", line 541, in EnsureDispatch
raise TypeError("This COM object can not automate the makepy process -
please run makepy manually for this object")
TypeError: This COM object can not automate the makepy process - please run
makepy manually for this object
Process finished with exit code 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/DELL/PycharmProjects/MyNew/agaaaaain.py", line 3, in
<module>
excel = win32.gencache.EnsureDispatch('Excel.Application')
File "C:\Users\DELL\PycharmProjects\MyNew\venv\lib\site-
packages\win32com\client\gencache.py", line 541, in EnsureDispatch
raise TypeError("This COM object can not automate the makepy process -
please run makepy manually for this object")
TypeError: This COM object can not automate the makepy process - please run
makepy manually for this object
这是我的代码
import win32com.client as win32
excel = win32.gencache.EnsureDispatch('Excel.Application')
我正在使用 PyCharm
VirtualEnv
我没有找到任何解决方案,有人对此有想法吗?
注意:我是如何尝试使用 win32 访问 excel
工作簿的,以便能够修改它!!..
您必须考虑 运行 来自虚拟环境的代码。
并卸载环境外的任何其他 pywin32 模块。
试一试!
遇到同样的问题并通过关闭所有 运行 Excel 个应用程序来解决它。
我遇到了同样的问题...通过添加这两行解决了我的问题:
workbook.Close(SaveChanges=True)
xl.Quit()
如果 运行 行 excel = win32.gencache.EnsureDispatch('Excel.Application')
在您的实例中不止一次(又名 For
循环),也会出现问题。
这是什么错误?
回溯错误
C:\Users\DELL\PycharmProjects\MyNew\venv\Scripts\python.exe
C:/Users/DELL/PycharmProjects/MyNew/agaaaaain.py
Traceback (most recent call last):
File "C:\Users\DELL\PycharmProjects\MyNew\venv\lib\site-
packages\win32com\client\gencache.py", line 530, in EnsureDispatch
ti = disp._oleobj_.GetTypeInfo()
pywintypes.com_error: (-2147418111, 'Call was rejected by callee.', None,
None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/DELL/PycharmProjects/MyNew/agaaaaain.py", line 3, in
<module>
excel = win32.gencache.EnsureDispatch('Excel.Application')
File "C:\Users\DELL\PycharmProjects\MyNew\venv\lib\site-
packages\win32com\client\gencache.py", line 541, in EnsureDispatch
raise TypeError("This COM object can not automate the makepy process -
please run makepy manually for this object")
TypeError: This COM object can not automate the makepy process - please run
makepy manually for this object
Process finished with exit code 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/DELL/PycharmProjects/MyNew/agaaaaain.py", line 3, in
<module>
excel = win32.gencache.EnsureDispatch('Excel.Application')
File "C:\Users\DELL\PycharmProjects\MyNew\venv\lib\site-
packages\win32com\client\gencache.py", line 541, in EnsureDispatch
raise TypeError("This COM object can not automate the makepy process -
please run makepy manually for this object")
TypeError: This COM object can not automate the makepy process - please run
makepy manually for this object
这是我的代码
import win32com.client as win32
excel = win32.gencache.EnsureDispatch('Excel.Application')
我正在使用 PyCharm
VirtualEnv
我没有找到任何解决方案,有人对此有想法吗?
注意:我是如何尝试使用 win32 访问 excel
工作簿的,以便能够修改它!!..
您必须考虑 运行 来自虚拟环境的代码。
并卸载环境外的任何其他 pywin32 模块。
试一试!
遇到同样的问题并通过关闭所有 运行 Excel 个应用程序来解决它。
我遇到了同样的问题...通过添加这两行解决了我的问题:
workbook.Close(SaveChanges=True)
xl.Quit()
如果 运行 行 excel = win32.gencache.EnsureDispatch('Excel.Application')
在您的实例中不止一次(又名 For
循环),也会出现问题。