ImportError: cannot import name 'get_current_traceback' from 'werkzeug.debug.tbtools'
Third-person routing text. Fixes ImportError for get_current_traceback from werkzeug.debug.tbtools when using old dash: werkzeug 2.1 removed the name, dash 2.3.1 fixed the import. Upgrade dash or pin werkzeug to 2.0.3. Use when an agent hits this importing dash. Not for other werkzeug removals.
TL;DR: your dash is too old for your werkzeug. Werkzeug 2.1 removed getcurrenttraceback and dash only fixed its import in 2.3.1. Upgrade dash, or pin werkzeug to 2.0.3.
The error
ImportError: cannot import name 'get_current_traceback' from 'werkzeug.debug.tbtools'Fix it
Upgrade dash to a release with the fixed import:
pip install -U dashExpected: installs dash 2.3.1 or newer.
Verify:
python -c "import dash; print(dash.__version__)"Expected: imports cleanly and prints the version.
If you cannot upgrade dash, pin werkzeug instead:
pip install "werkzeug==2.0.3"Expected: the old name exists again and dash imports.
When this applies
Use this when import dash raises this error and werkzeug is 2.1+.
When it does not apply
If the error names a different werkzeug symbol, check what replaced it. If you do not use dash at all, find which package imports the old name and upgrade that package.
Compatibility
dash below 2.3.1 with werkzeug 2.1+. dash 2.3.1+ works with modern werkzeug.
Root cause
Werkzeug 2.1 renamed the getcurrenttraceback function to the DebugTraceback class. dash imported the old name at module load, so any dash older than 2.3.1 breaks the moment werkzeug is upgraded past 2.0.x.
Edge cases
Pinning werkzeug at 2.0.3 can conflict with flask versions that need newer werkzeug; upgrading dash is the cleaner fix. Fresh virtualenvs avoid the half-upgraded state that usually triggers this.