Bench start failing - ModuleNotFoundError: No module named 'werkzeug'

bench start
    
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py:844: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
      self.stdout = io.open(c2pread, 'rb', bufsize)
    /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py:844: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
      self.stdout = io.open(c2pread, 'rb', bufsize)
    /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py:844: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
      self.stdout = io.open(c2pread, 'rb', bufsize)
    10:44:40 system           | redis_cache.1 started (pid=73864)
    10:44:40 system           | web.1 started (pid=73866)
    10:44:40 system           | redis_queue.1 started (pid=73865)
    /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py:844: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
      self.stdout = io.open(c2pread, 'rb', bufsize)
    10:44:40 redis_cache.1    | 73864:C 21 Apr 2020 10:44:40.771 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
    10:44:40 redis_cache.1    | 73864:C 21 Apr 2020 10:44:40.771 # Redis version=5.0.9, bits=64, commit=00000000, modified=0, pid=73864, just started
    10:44:40 redis_cache.1    | 73864:C 21 Apr 2020 10:44:40.771 # Configuration loaded
    10:44:40 redis_cache.1    | 73864:M 21 Apr 2020 10:44:40.774 * Running mode=standalone, port=13000.
    10:44:40 redis_cache.1    | 73864:M 21 Apr 2020 10:44:40.774 # Server initialized
    10:44:40 redis_cache.1    | 73864:M 21 Apr 2020 10:44:40.774 * Ready to accept connections
    /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py:844: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
      self.stdout = io.open(c2pread, 'rb', bufsize)
    10:44:40 redis_queue.1    | 73865:C 21 Apr 2020 10:44:40.776 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
    10:44:40 redis_queue.1    | 73865:C 21 Apr 2020 10:44:40.776 # Redis version=5.0.9, bits=64, commit=00000000, modified=0, pid=73865, just started
    10:44:40 redis_queue.1    | 73865:C 21 Apr 2020 10:44:40.776 # Configuration loaded
    10:44:40 system           | socketio.1 started (pid=73867)
    /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py:844: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
      self.stdout = io.open(c2pread, 'rb', bufsize)
    10:44:40 redis_queue.1    | 73865:M 21 Apr 2020 10:44:40.779 * Running mode=standalone, port=11000.
    10:44:40 redis_queue.1    | 73865:M 21 Apr 2020 10:44:40.779 # Server initialized
    10:44:40 redis_queue.1    | 73865:M 21 Apr 2020 10:44:40.779 * Ready to accept connections
    10:44:40 system           | redis_socketio.1 started (pid=73868)
    10:44:40 system           | watch.1 started (pid=73869)
    /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py:844: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
      self.stdout = io.open(c2pread, 'rb', bufsize)
    /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py:844: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
      self.stdout = io.open(c2pread, 'rb', bufsize)
    10:44:40 system           | schedule.1 started (pid=73870)
    10:44:40 redis_socketio.1 | 73868:C 21 Apr 2020 10:44:40.791 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
    10:44:40 redis_socketio.1 | 73868:C 21 Apr 2020 10:44:40.791 # Redis version=5.0.9, bits=64, commit=00000000, modified=0, pid=73868, just started
    10:44:40 redis_socketio.1 | 73868:C 21 Apr 2020 10:44:40.791 # Configuration loaded
    10:44:40 redis_socketio.1 | 73868:M 21 Apr 2020 10:44:40.794 * Running mode=standalone, port=12000.
    10:44:40 redis_socketio.1 | 73868:M 21 Apr 2020 10:44:40.794 # Server initialized
    10:44:40 redis_socketio.1 | 73868:M 21 Apr 2020 10:44:40.794 * Ready to accept connections
    10:44:40 system           | worker_short.1 started (pid=73871)
    /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py:844: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
      self.stdout = io.open(c2pread, 'rb', bufsize)
    /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py:844: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
      self.stdout = io.open(c2pread, 'rb', bufsize)
    10:44:40 system           | worker_default.1 started (pid=73872)
    10:44:40 system           | worker_long.1 started (pid=73873)
    10:44:41 socketio.1       | listening on *: 9000
    10:44:41 worker_long.1    | WARN: bench is installed in editable mode!
    10:44:41 worker_long.1    | 
    10:44:41 worker_long.1    | This is not the recommended mode of installation for production. Instead, install the package from PyPI with: `pip install frappe-bench`
    10:44:41 worker_long.1    | 
    10:44:41 watch.1          | WARN: bench is installed in editable mode!
    10:44:41 watch.1          | 
    10:44:41 watch.1          | This is not the recommended mode of installation for production. Instead, install the package from PyPI with: `pip install frappe-bench`
    10:44:41 watch.1          | 
    10:44:41 worker_default.1 | WARN: bench is installed in editable mode!
    10:44:41 worker_default.1 | 
    10:44:41 worker_default.1 | This is not the recommended mode of installation for production. Instead, install the package from PyPI with: `pip install frappe-bench`
    10:44:41 worker_default.1 | 
    10:44:41 web.1            | WARN: bench is installed in editable mode!
    10:44:41 web.1            | 
    10:44:41 web.1            | This is not the recommended mode of installation for production. Instead, install the package from PyPI with: `pip install frappe-bench`
    10:44:41 web.1            | 
    10:44:41 schedule.1       | WARN: bench is installed in editable mode!
    10:44:41 schedule.1       | 
    10:44:41 schedule.1       | This is not the recommended mode of installation for production. Instead, install the package from PyPI with: `pip install frappe-bench`
    10:44:41 schedule.1       | 
    10:44:41 worker_short.1   | WARN: bench is installed in editable mode!
    10:44:41 worker_short.1   | 
    10:44:41 worker_short.1   | This is not the recommended mode of installation for production. Instead, install the package from PyPI with: `pip install frappe-bench`
    10:44:41 worker_short.1   | 
    10:44:42 web.1            |  * Running on http://0.0.0.0:8000/ (Press CTRL+C to quit)
    10:44:42 web.1            |  * Restarting with fsevents reloader
    10:44:42 watch.1          | yarn run v1.22.4
    10:44:42 web.1            | Traceback (most recent call last):
    10:44:42 web.1            |   File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 184, in _run_module_as_main
    10:44:42 web.1            |     mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
    10:44:42 web.1            |   File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 110, in _get_module_details
    10:44:42 web.1            |     __import__(pkg_name)
    10:44:42 web.1            |   File "/Users/deschantkounou/dev/frappe-bench/apps/frappe/frappe/__init__.py", line 10, in <module>
    10:44:42 web.1            |     from werkzeug.local import Local, release_local
    10:44:42 web.1            | ModuleNotFoundError: No module named 'werkzeug'
    10:44:42 watch.1          | $ node rollup/watch.js
    10:44:42 system           | web.1 stopped (rc=1)
    10:44:42 system           | sending SIGTERM to redis_cache.1 (pid 73864)
    10:44:42 system           | sending SIGTERM to redis_socketio.1 (pid 73868)
    10:44:42 system           | sending SIGTERM to redis_queue.1 (pid 73865)
    10:44:42 system           | sending SIGTERM to socketio.1 (pid 73867)
    10:44:42 system           | sending SIGTERM to watch.1 (pid 73869)
    10:44:42 system           | sending SIGTERM to schedule.1 (pid 73870)
    10:44:42 system           | sending SIGTERM to worker_short.1 (pid 73871)
    10:44:42 system           | sending SIGTERM to worker_long.1 (pid 73873)
    10:44:42 system           | sending SIGTERM to worker_default.1 (pid 73872)
    10:44:42 redis_cache.1    | 73864:signal-handler (1587458682) Received SIGTERM scheduling shutdown...
    10:44:42 redis_socketio.1 | 73868:signal-handler (1587458682) Received SIGTERM scheduling shutdown...
    10:44:42 redis_queue.1    | 73865:signal-handler (1587458682) Received SIGTERM scheduling shutdown...
    10:44:42 system           | socketio.1 stopped (rc=-15)
    10:44:42 system           | schedule.1 stopped (rc=-15)
    10:44:42 system           | watch.1 stopped (rc=-15)
    10:44:42 redis_cache.1    | 73864:M 21 Apr 2020 10:44:42.627 # User requested shutdown...
    10:44:42 redis_queue.1    | 73865:M 21 Apr 2020 10:44:42.627 # User requested shutdown...
    10:44:42 redis_cache.1    | 73864:M 21 Apr 2020 10:44:42.627 * Removing the pid file.
    10:44:42 redis_queue.1    | 73865:M 21 Apr 2020 10:44:42.627 * Removing the pid file.
    10:44:42 redis_cache.1    | 73864:M 21 Apr 2020 10:44:42.627 # Redis is now ready to exit, bye bye...
    10:44:42 redis_queue.1    | 73865:M 21 Apr 2020 10:44:42.627 # Redis is now ready to exit, bye bye...
    10:44:42 system           | redis_cache.1 stopped (rc=0)
    10:44:42 system           | redis_queue.1 stopped (rc=0)
    10:44:42 redis_socketio.1 | 73868:M 21 Apr 2020 10:44:42.640 # User requested shutdown...
    10:44:42 redis_socketio.1 | 73868:M 21 Apr 2020 10:44:42.640 * Removing the pid file.
    10:44:42 redis_socketio.1 | 73868:M 21 Apr 2020 10:44:42.640 # Redis is now ready to exit, bye bye...
    10:44:42 system           | redis_socketio.1 stopped (rc=0)
    10:44:42 system           | worker_long.1 stopped (rc=0)
    10:44:42 system           | worker_default.1 stopped (rc=0)
    10:44:42 system           | worker_short.1 stopped (rc=0)

I have tried running ./env/bin/pip install werkzeug==0.16.1 inside my frappe-bench directory but still nothing.

Any help would be much appreciated.

@deschant, are you working on a MacOS system?

It seems to be picking up your user Python environment instead of the bench’s.

I’m not sure of a proper fix, but as a workaround (only recommended if you don’t have any other apps using Python locally), you might want to install / re-install werkzeug in your local Python environment.

Yes @RohanB I am using MacOS.
I have a fresh python3.8 installation. Might there be some common configuration that I could be missing which would cause this ?

I’m not sure actually. I’ve seen this happen on another colleague’s system, but he wasn’t using Python for any other application, so the workaround was enough for work :sweat_smile:

Try this:

./env/bin/pip3 install werkzeug==0.16.1
(Installs in bench python3 virtual environment)

Or just pip3 install werkzeug==0.16.1
(Installs in python3 environment)