New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
m0xb opened this Issue Dec 6, 2016 · 14 comments

Comments

Projects
None yet
5 participants
@m0xb

m0xb commented Dec 6, 2016

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?

@waylan

This comment has been minimized.

Member

waylan commented Dec 6, 2016

Which versions of livereload and tornado do you have?

Perhaps you can try updating them to the latest versions:

pip install -U tornado livereload
@m0xb

This comment has been minimized.

m0xb commented Dec 7, 2016

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.

@waylan

This comment has been minimized.

Member

waylan commented Dec 7, 2016

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.

@d0ugal

This comment has been minimized.

Member

d0ugal commented Dec 7, 2016

@d0ugal

This comment has been minimized.

Member

d0ugal commented Dec 7, 2016

@waylan

This comment has been minimized.

Member

waylan commented Dec 7, 2016

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.

@d0ugal

This comment has been minimized.

Member

d0ugal commented Dec 7, 2016

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?

@waylan

This comment has been minimized.

Member

waylan commented Dec 8, 2016

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.

@ErichBSchulz

This comment has been minimized.

ErichBSchulz commented Jan 6, 2017

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'
@ErichBSchulz

This comment has been minimized.

ErichBSchulz commented Jan 6, 2017

related issue: clonn/simple-livereload#1

@ErichBSchulz

This comment has been minimized.

ErichBSchulz commented Jan 6, 2017

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)

@waylan

This comment has been minimized.

Member

waylan commented Jan 7, 2017

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.

@lepture

This comment has been minimized.

lepture commented Jan 7, 2017

@waylan A new version of livereload is released.

@waylan

This comment has been minimized.

Member

waylan commented Jan 7, 2017

@lepture awesome! Thanks.

waylan added a commit to waylan/mkdocs that referenced this issue Jan 8, 2017

Up livereload version to =>2.5.1.
This ensures older pyinotify versions don't break the livereload server.
Fixes mkdocs#1106.

@waylan waylan closed this in #1122 Jan 8, 2017

waylan added a commit that referenced this issue Jan 8, 2017

Up livereload version to >=2.5.1. (#1122)
This ensures older pyinotify versions don't break the livereload server.
Fixes #1106.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment