Search code examples
pythonubuntuflaskdigital-oceanwinreg

Missing Windows module in Flask app running on Ubuntu Droplet


I'm trying to run a Flask app on an Ubuntu Droplet but when I try to run the app with python app.py I get the following traceback:

* Running on http://0.0.0.0:4000/ (Press CTRL+C to quit)
 * Restarting with stat
Traceback (most recent call last):
  File "app.py", line 49, in <module>
    app.run('0.0.0.0', port=4000, debug=True)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 772, in run
    run_simple(host, port, self, **options)
  File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 622, in run_simple
    reloader_type)
  File "/usr/local/lib/python2.7/dist-packages/werkzeug/_reloader.py", line 269, in run_with_reloader
    reloader.run()
  File "/usr/local/lib/python2.7/dist-packages/werkzeug/_reloader.py", line 159, in run
    for filename in chain(_iter_module_files(), self.extra_files):
  File "/usr/local/lib/python2.7/dist-packages/werkzeug/_reloader.py", line 70, in _iter_module_files
    for package_path in getattr(module, '__path__', ()):
  File "/usr/lib/python2.7/dist-packages/six.py", line 116, in __getattr__
    _module = self._resolve()
  File "/usr/lib/python2.7/dist-packages/six.py", line 105, in _resolve
    return _import_module(self.mod)
  File "/usr/lib/python2.7/dist-packages/six.py", line 76, in _import_module
    __import__(name)
ImportError: No module named _winreg

I can't install the package with pip or apt-get since I'm pretty sure this is a Windows-specific module. Is there any way I can get around this?


Solution

  • I was having the same problem. As far as I understand it is because of a few changes in the last Werkzeug version that changes the reloader.

    Installing the watchdog could solve my problem:

    pip install watchdog

    And now, instead of seeing "* Restart with stat" I'm seeing "* Restart with inotify reloader" and it is all working fine.