Bench console breaks often

I’m using the latest version from the develop branch and I often get this error:

Traceback (most recent call last):
  File "/home/punk/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 48, in invoke
    return super().invoke(ctx)
  File "/home/punk/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1830, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/punk/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1226, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/punk/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 794, in invoke
    return callback(*args, **kwargs)
  File "/home/punk/frappe-bench/env/lib/python3.10/site-packages/click/decorators.py", line 34, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/punk/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 28, in _func
    ret = f(ctx.obj, *args, **kwargs)
  File "/home/punk/frappe-bench/apps/frappe/frappe/commands/utils.py", line 646, in console
    from IPython.terminal.embed import InteractiveShellEmbed
  File "/home/punk/frappe-bench/env/lib/python3.10/site-packages/IPython/__init__.py", line 53, in <module>
    from .core.application import Application
  File "/home/punk/frappe-bench/env/lib/python3.10/site-packages/IPython/core/application.py", line 26, in <module>
    from IPython.core import release, crashhandler
  File "/home/punk/frappe-bench/env/lib/python3.10/site-packages/IPython/core/crashhandler.py", line 27, in <module>
    from IPython.core import ultratb
  File "/home/punk/frappe-bench/env/lib/python3.10/site-packages/IPython/core/ultratb.py", line 111, in <module>
    from IPython.core import debugger
  File "/home/punk/frappe-bench/env/lib/python3.10/site-packages/IPython/core/debugger.py", line 122, in <module>
    from pdb import Pdb as OldPdb
  File "/home/punk/frappe-bench/env/lib/python3.10/site-packages/_pdbpp_path_hack/pdb.py", line 5, in <module>
    exec(compile(f.read(), pdb_path, 'exec'))
  File "/home/punk/frappe-bench/env/lib/python3.10/site-packages/pdb.py", line 28, in <module>
    __version__ = fancycompleter.LazyVersion('pdbpp')
AttributeError: module 'fancycompleter' has no attribute 'LazyVersion'

module 'fancycompleter' has no attribute 'LazyVersion'

I have already run bench setup requirements --dev. The last time I had to reinstall the virtual environment to resolve the issue, and now suddenly again I’ve run into the same error as before.

If I upgrade the pdbpp version from 0.10.3 to 0.11.6 then this problem goes away, so do we really need this to be pinned to this old version?

I have had errors like these come up due to some caching issue when there are different versions of py in the machine… they go away on server restart or maybe even supervisorctl reload… whatever clears the cache