serialnumber
serialnumber

Reputation: 43

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

Upvotes: 4

Views: 6888

Answers (1)

Mihail Feraru
Mihail Feraru

Reputation: 1479

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.

Upvotes: 17

Related Questions