'Watchdog: FileNotFoundError: [WinError 2] Systém nemůže nalézt uvedený soubor
So I have my code to move file from one folder to another.
import watchdog
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
import os
import json
import time
class MyHandler(FileSystemEventHandler):
def on_modified(self, event):
for filename in os.listdir(folder_to_track):
src = folder_to_track + "/" + filename
new_destination = folder_destination + "/" + filename
os.rename(src, new_destination)
folder_to_track = "/Folder"
folder_destination = "/Filmy"
event_handler = MyHandler()
observer = Observer()
observer.schedule(event_handler, folder_to_track, recursive=True)
observer.start()
try:
while True:
time.sleep(10)
except KeyboardInterrupt:
observer.stop()
observer.join()
And I get the following error:
Traceback (most recent call last):
File "C:\Python\Projects\pygame\file_mover.py", line 21, in <module>
observer.start()
File "C:\Users\Marek\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\watchdog\observers\api.py", line 256, in start
emitter.start()
File "C:\Users\Marek\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\watchdog\utils\__init__.py", line 93, in start
self.on_thread_start()
File "C:\Users\Marek\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\watchdog\observers\read_directory_changes.py", line 67, in on_thread_start
self._handle = get_directory_handle(self.watch.path)
File "C:\Users\Marek\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\watchdog\observers\winapi.py", line 316, in get_directory_handle
return CreateFileW(path, FILE_LIST_DIRECTORY, WATCHDOG_FILE_SHARE_FLAGS,
File "C:\Users\Marek\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\watchdog\observers\winapi.py", line 112, in _errcheck_handle
raise ctypes.WinError()
FileNotFoundError: [WinError 2] Systém nemůže nalézt uvedený soubor.
How can this be fixed?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
