12

Im trying to run official watchdog simple example after installing the watchdog module using pip: pip install watchdog, and i get an error:

from watchdog.observers import Observer
ImportError: No module named observers

Can someone please help me?

Sagar Hatekar
  • 8,700
  • 14
  • 56
  • 72
scythargon
  • 3,363
  • 3
  • 32
  • 62
  • it seems that it was too short question before... – scythargon Aug 06 '12 at 17:34
  • 1
    Did watchdog installation complete succesflly. Can you try "import watchdog" in interactive Python interpreter. – Mikko Ohtamaa Aug 06 '12 at 17:45
  • And what is the exact Python environment / command you used to install watchdog? Did you install it in system libraries? – Mikko Ohtamaa Aug 06 '12 at 17:46
  • @MikkoOhtamaa: OP already said they used PIP – jdi Aug 06 '12 at 17:47
  • 1
    pip install itself should not do anything unless you run it as a root or have virtualenv activated. Also the installation log is missing and the author's installation may simply have failed. – Mikko Ohtamaa Aug 06 '12 at 17:47
  • 4
    @MikkoOhtamaa: What are you talking about? pip is not bound to virtualenv, nor is it bound to being run as root. If your python site-packages isn't locked down, it works just fine. And I don't know why you got a +1 for that statement – jdi Aug 06 '12 at 17:48
  • 1
    FWIW, I just used `pip install watchdog` to install it on my OS X system (not being root or using virtualenv), and everything worked as it should. – DSM Aug 06 '12 at 17:51
  • @DSM: Exactly. That statement by Mikko is making presumptions about the permissions of your python installation and your platform. – jdi Aug 06 '12 at 17:52
  • 5
    oh, guys, sorry for this alarm, it is caused that named my file 'watchdog.py', my bad. thanks a lot:) – scythargon Aug 06 '12 at 17:52
  • @SagarHatekar I would like, but I cant: 'Uncaught TypeError: Property 'confirm' of object [object Window] is not a function importerror-no-module-named-observers-after-installed-watchdog:603 (anonymous function) importerror-no-module-named-observers-after-installed-watchdog:603 f.event.dispatch jquery.min.js:3 f.event.add.h.handle.i jquery.min.js:3 ' - when I click "Answer your Question" – scythargon Aug 06 '12 at 22:05
  • @scythargon Just copy and paste the following text in your answer. "I figured the cause for the ImportError issue. My module name was the same as the module I was trying to import. Renaming my module to something else other than watchdog or observers resolved this issue. Thanks all for your help!" – Sagar Hatekar Aug 06 '12 at 22:43
  • @SagarHatekar thanks a lot, e. are you kidding? I said - there are JavaScript error when I press "Answer Your Question" in the bottom of the page. – scythargon Aug 06 '12 at 23:53
  • @scythargon Exactly! There's something funny in that comment which SO doesn't like! :) – Sagar Hatekar Aug 07 '12 at 00:39
  • 1
    Had the same problem, thanks. For others also needed to manually delete my "watchdog.pyc" before it would work – Mtl Dev Dec 08 '16 at 20:18

1 Answers1

27

I figured the cause for the ImportError issue. My module name was the same as the module I was trying to import. Renaming my module to something else other than watchdog or observers resolved this issue. Thanks all for your help!

scythargon
  • 3,363
  • 3
  • 32
  • 62