Search code examples
pythonfile-managementpython-watchdog

No module named 'watchdog.observers'; 'watchdog' is not a package


I installed watchdog but trying to run any code doesn't work. I get that error message. Here's the code snippet. Any ideas on how to fix this?

Console Screenshot


Solution

  • Well, that's a very old and common issue when using Python packages. You named your file watchdog.py and the name of the package you use is watchdog too, so when you are trying to run from watchdog.observers import ... the interpreter would get confused and would try to import the current script itself.

    Just rename the script to something else and everything should be all right.