Error: ModuleNotFoundError: No module named 'listview_extend' even after removing custom app

I had previously installed a custom app named listview_extend, but I have since deleted the app directory. Now, whenever I run bench --site frontend migrate or bench clear-cache, I get the following error:

frappe@6e77847f24ea:~/frappe-bench$ bench --site frontend clear-cache
Could not find app “listview_extend”:
No module named ‘listview_extend’
Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/caching.py”, line 57, in wrapper
return frappe.local.request_cache[func][args_key]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
KeyError: 5740354900026072187

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “”, line 198, in _run_module_as_main
File “”, line 88, in _run_code
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 114, in
main()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 20, in main
click.Group(commands=commands)(prog_name=“bench”)
File “/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py”, line 1161, in call
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py”, line 1082, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File “/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py”, line 1697, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py”, line 1697, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py”, line 1443, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py”, line 788, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/decorators.py”, line 33, in new_func
return f(get_current_context(), *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/init.py”, line 29, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/utils.py”, line 118, in clear_cache
frappe.clear_cache()
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 975, in clear_cache
for key in frappe.get_hooks(“persistent_cache_keys”):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 1599, in get_hooks
hooks = _dict(_load_app_hooks())
^^^^^^^^^^^^^^^^^
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/caching.py”, line 59, in wrapper
return_val = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 1568, in _load_app_hooks
app_hooks = get_module(f"{app}.hooks")
^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 1434, in get_module
return importlib.import_module(modulename)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “”, line 1204, in _gcd_import
File “”, line 1176, in _find_and_load
File “”, line 1126, in _find_and_load_unlocked
File “”, line 241, in _call_with_frames_removed
File “”, line 1204, in _gcd_import
File “”, line 1176, in _find_and_load
File “”, line 1140, in _find_and_load_unlocked
ModuleNotFoundError: No module named ‘listview_extend’

@SowmyahMallela Since you removed the listview_extend app directory manually, go to the sites directory and remove listview_extend app from the apps.json and apps.txt file.

From next time, after uninstall the custom app app from site, use

bench remove-app app_name

to remove the app.

Thanks @Kiranmai_M
I’ve removed listview_extend from both apps.json and apps.txt as suggested. But I’m still getting the same error

@SowmyahMallela , You can try the following:

  1. Remove from apps.txt , apps.json , configs
  2. bench --site sitename uninstall-app listview_extend --yes --force
  3. bench restart and bench clear-cache

Thanks,
Sukhman