Try ERPNext Buy Support Partners Foundation

ModuleNotFoundError: No module named 'werkzeug.contrib' (erpnext 12.4.3)

Immediately after installation, this error appears dozens of times in my log file:
/home/erpnext/frappe-bench/logs/web.error.log

Traceback (most recent call last):
  File "/home/erpnext/frappe-bench/env/bin/gunicorn", line 8, in <module>
    sys.exit(run())
  File "/home/erpnext/frappe-bench/env/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 58, in run
    WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
  File "/home/erpnext/frappe-bench/env/lib/python3.6/site-packages/gunicorn/app/base.py", line 228, in run
    super().run()
  File "/home/erpnext/frappe-bench/env/lib/python3.6/site-packages/gunicorn/app/base.py", line 72, in run
    Arbiter(self).run()
  File "/home/erpnext/frappe-bench/env/lib/python3.6/site-packages/gunicorn/arbiter.py", line 58, in __init__
    self.setup(app)
  File "/home/erpnext/frappe-bench/env/lib/python3.6/site-packages/gunicorn/arbiter.py", line 118, in setup
    self.app.wsgi()
  File "/home/erpnext/frappe-bench/env/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/home/erpnext/frappe-bench/env/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
    return self.load_wsgiapp()
  File "/home/erpnext/frappe-bench/env/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/home/erpnext/frappe-bench/env/lib/python3.6/site-packages/gunicorn/util.py", line 358, in import_app
    mod = importlib.import_module(module)
  File "/home/erpnext/frappe-bench/env/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/app.py", line 13, in <module>
    from werkzeug.contrib.profiler import ProfilerMiddleware
ModuleNotFoundError: No module named 'werkzeug.contrib'

I am using install.py that I obtain with:

wget -nc https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py;

The resulting web site shows only the page:
"Sorry!
We will be back soon."

Version stuff …

erpnext@admin:~/frappe-bench$ bench --version
4.1.0

erpnext@admin:~/frappe-bench$ bench version
erpnext 12.4.3
frappe 12.2.1

erpnext@admin:~/frappe-bench$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.4 LTS
Release:	18.04
Codename:	bionic

I would be grateful for any hints of how to debug this.

1 Like

You should downgrade Werkzeug to the version 0.16.4.

4 Likes

I was about to try running install.py --version 12.4.2 would that also downgrade Werkzeug?

If not, would you kindly explain how to downgrade Werkzeug?

You can look at this post: https://stackoverflow.com/questions/30564332/how-to-download-previous-version-of-werkzeug

Yes, that command is going to have the same problem.

1 Like

thanx for your help
:+1:

trying that now . . . . . . .

So I did . . .

cd ${HOME/}frappe-bench
./env/bin/pip install werkzeug==0.16.0

. . . and rebooted the server.

Everything now back to normal.

(but 4 hours of my life down the toilet)

7 Likes

werkzueg version has been pinned to 0.16.0 in frappe’s requirements.txt

1 Like

it was applied for develop branch not production version-12, still the error happen when you easy install fresh installation --production

@ahmadRagheb Yes you are right. Any solution to this? As I already downgrade… but still having the same problem. I am using Easy Installation.

Have you tried :

cd ${HOME/}frappe-bench;
./env/bin/pip list

It should show you the versions of all pip installed dependencies. The last one, Werkzeug, should be 0.16.0

This one worked for me. I have wasted two hours trying to troubleshoot Nginx. Thanks alot

Dear all, it finally work after I reinstall everything, and downgrade the Werkzeug using command above…

Thanks, and cheers.

This should fix it for version-12