小编Rob*_*101的帖子

pywintypes.com_error:(-2147221008,'CoInitialize尚未被调用。',无,无)

当我尝试按原样运行此代码时,出现此错误“IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) pywintypes.com_error: (-2147221008, 'CoInitialize 尚未被调用。', None, None )" ,但是如果我单独运行 stp_tracker ,它工作得很好,如果我单独运行 notify stp ,它工作得很好。我感谢任何人的意见。谢谢

import time
import win32com.client
# import sys
from watchdog.observers import Observer
from watchdog.events import PatternMatchingEventHandler
# import watchdog


class MyHandler(PatternMatchingEventHandler):
    patterns = ["*.stp", "*.step", "*.txt"]

    def process(self, event):
        """
        event.event_type
            'modified' | 'created' | 'moved' | 'deleted'
        event.is_directory
            True | False
        event.src_path
            path/to/observed/file
        """
        # the file will be processed there
        print(event.src_path, event.event_type)

    def on_modified(self, event):
        self.process(event)
        notify_stps()

    def on_created(self, event): …
Run Code Online (Sandbox Code Playgroud)

python events winapi pywin32 watchdog

6
推荐指数
2
解决办法
2万
查看次数

标签 统计

events ×1

python ×1

pywin32 ×1

watchdog ×1

winapi ×1