Skip to content

AttributeError: 'module' object has no attribute 'TornadoAsyncNotifier' #1106

Description

@m0xb

Using Python 2.6.6 on CentOS, I'm unable to run the server with livereload:

[mkdocs@dev test-docs]$ python /home/mkdocs/.local/lib/python2.6/site-packages/mkdocs/__main__.py serve --dev-addr=0.0.0.0:8080
WARNING: Support for Python 2.6 will be dropped in the 1.0.0 release of MkDocs

INFO    -  Building documentation... 
INFO    -  Cleaning site directory 
[I 161205 22:16:26 server:283] Serving on http://0.0.0.0:8080
[I 161205 22:16:26 handlers:60] Start watching changes
Traceback (most recent call last):
  File "/home/mkdocs/.local/lib/python2.6/site-packages/mkdocs/__main__.py", line 227, in <module>
    cli()
  File "/home/mkdocs/.local/lib/python2.6/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/home/mkdocs/.local/lib/python2.6/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/home/mkdocs/.local/lib/python2.6/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/mkdocs/.local/lib/python2.6/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/mkdocs/.local/lib/python2.6/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/home/mkdocs/.local/lib/python2.6/site-packages/mkdocs/__main__.py", line 127, in serve_command
    livereload=livereload
  File "/home/mkdocs/.local/lib/python2.6/site-packages/mkdocs/commands/serve.py", line 88, in serve
    _livereload(host, port, config, builder, tempdir)
  File "/home/mkdocs/.local/lib/python2.6/site-packages/mkdocs/commands/serve.py", line 27, in _livereload
    server.serve(root=site_dir, host=host, port=int(port), restart_delay=0)
  File "/home/mkdocs/.local/lib/python2.6/site-packages/livereload/server.py", line 300, in serve
    LiveReloadHandler.start_tasks()
  File "/home/mkdocs/.local/lib/python2.6/site-packages/livereload/handlers.py", line 61, in start_tasks
    if not cls.watcher.start(cls.poll_tasks):
  File "/home/mkdocs/.local/lib/python2.6/site-packages/livereload/watcher.py", line 160, in start
    self.notifier = pyinotify.TornadoAsyncNotifier(
AttributeError: 'module' object has no attribute 'TornadoAsyncNotifier'

I can workaround by using --no-livereload, but is there a way to get livereload working?

Activity

  1. waylan commented on Dec 6, 2016

    @waylan
    Contributor

    Which versions of livereload and tornado do you have?

    Perhaps you can try updating them to the latest versions:

    pip install -U tornado livereload
    
  2. m0xb commented on Dec 7, 2016

    @m0xb
    Author

    I have livereload 2.5.0 and tornado 4.4.2, both installed locally for my user. pip install -U tells me both are up-to-date.

  3. waylan commented on Dec 7, 2016

    @waylan
    Contributor

    I can't reproduce this locally. I wonder if this is a Python 2.6 incompatibility. I don't have that installed locally so I can't test this myself and our automated tests aren't having any problem, although they don't necessarily test the third party libs we use.

    As a test, let's see if livereload is working on its own by manually building the site and using livereload directly. Try the following commands:

    mkdocs build
    cd site
    livereload

    If that raises the same error, then the problem is upstream. If not, then we have a problem with MkDocs use of livereload.

    As an aside, using livereload like that won't work the same as using our wrapper. You would still need to build manually every time. With our wrapper, the builds are automated too.

  4. d0ugal commented on Dec 7, 2016

    @d0ugal
    Contributor
  5. d0ugal commented on Dec 7, 2016

    @d0ugal
    Contributor
  6. waylan commented on Dec 7, 2016

    @waylan
    Contributor

    Travis is still running the PY2.6 tests so I assumed it still works. I realize Python-Markdown dropped support some time ago but I assumed MkDocs still worked with an older version. Perhaps the few untested areas are the problem.

    In fact I ran into a few problems with 2.6 tests failing (which I was able to resolve) when trying to get 0.16 out the door. I'm happy to see it go. Just didn't think we were there yet.

  7. d0ugal commented on Dec 7, 2016

    @d0ugal
    Contributor

    That is a good point, I forgot Travis covered this - maybe I done something wrong with my test. I'll try again tomorrow.

    The plan was to drop it for 1.0 anyway, so we can do that soon. Seems 0.16 is pretty solid - maybe we just do a quick release with the couple of bug fixes and then start the cleanup?

  8. waylan commented on Dec 8, 2016

    @waylan
    Contributor

    The plan was to drop it for 1.0 anyway, so we can do that soon. Seems 0.16 is pretty solid - maybe we just do a quick release with the couple of bug fixes and then start the cleanup?

    That was my thinking as well.

  9. ErichBSchulz commented on Jan 6, 2017

    @ErichBSchulz

    I am hitting this... is there an easy fix?

    I'm on Python 2.7.3 (default, Jun 22 2015, 19:33:41)
    [GCC 4.6.3] on linux2

    and if it helps I tried

    mkdocs build
    cd /home/erich/civicrm-dev-docs/site 
    livereload 
    

    and got a similar error:

    [I 170106 22:02:35 server:283] Serving on http://127.0.0.1:35729
    [I 170106 22:02:35 handlers:60] Start watching changes
    Traceback (most recent call last):
      File "/usr/local/bin/livereload", line 9, in <module>
        load_entry_point('livereload==2.5.0', 'console_scripts', 'livereload')()
      File "/usr/local/lib/python2.7/dist-packages/livereload/cli.py", line 39, in 
    main
        server.serve(host=args.host, port=args.port, root=args.directory)
      File "/usr/local/lib/python2.7/dist-packages/livereload/server.py", line 300,
     in serve
        LiveReloadHandler.start_tasks()
      File "/usr/local/lib/python2.7/dist-packages/livereload/handlers.py", line 61
    , in start_tasks
        if not cls.watcher.start(cls.poll_tasks):
      File "/usr/local/lib/python2.7/dist-packages/livereload/watcher.py", line 160
    , in start
        self.notifier = pyinotify.TornadoAsyncNotifier(
    AttributeError: 'module' object has no attribute 'TornadoAsyncNotifier'
    
  10. ErichBSchulz commented on Jan 6, 2017

    @ErichBSchulz
  11. ErichBSchulz commented on Jan 6, 2017

    @ErichBSchulz

    ok so I've fixed this on my machine with

      sudo pip install pyinotify --upgrade
    

    (was on pyinotify==0.9.2 not on pyinotify==0.9.6)

  12. waylan commented on Jan 7, 2017

    @waylan
    Contributor

    related issue: clonn/simple-livereload#1

    Hmm, interesting as that is the Node/JavaScript livereload lib. Regardless, thanks for the workaround (upgrading pyinotify) @ErichBSchulz. Turns out that lepture/python-livereload requires at least pyinotify=>0.9.4.

    In an effort to track this down, I noticed that pyinotify is not listed as a dependency of either lepture/python-livereload or its dependencies. In fact, it isn't even installed on my virtualenvs (I checked with pip freeze). But, with a little digging, I see that the import fails gracefully and a different code-path is followed when the lib is not installed.

    pyinotify is a Linux-specific lib and not available on other platforms (thus python-livereload's graceful fallback). In fact, I haven't noticed any issues with it not being installed on my local Linux system. That said, it is a wrapper around the inotify lib and is likely much more performant than the home-grown system for other platforms. We can't expect users to not have it installed, and there is no reasonable way to force users who do to upgrade (if needed) when python-livereload is installed.

    Regardless, this should be an upstream issue for python-livereload. lepture/python-livereload#143 already raises the issue that pyinotify support is not documented. I opened lepture/python-livereload#148 to add a check for the pyinotify version and fallback gracefully if an older version is installed.

    Once that (or a similar fix) gets accepted and included in a new version of python-livereload, we can update our version requirement for that lib. Until then, we'll leave this open to remind us.

  13. lepture commented on Jan 7, 2017

    @lepture

    @waylan A new version of livereload is released.

  14. waylan commented on Jan 7, 2017

    @waylan
    Contributor

    @lepture awesome! Thanks.

  15. added a commit that references this issue on Jan 8, 2017
    0cbd6c3
  16. added a commit that references this issue on Jan 8, 2017
    3c8a1fc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions