ModuleNotFoundError: No module named 'ui_theme'

I added a custom application precisely Module Not Found Error.

  1. result from sites/apps.txt
  2. result from ls apps/
    image
  3. result from bench --site frontend install-app ui_theme
  4. the result

ModuleNotFoundError
ModuleNotFoundError: No module named ‘ui_theme’

Traceback (most recent call last)
This is the Copy/Paste friendly version of the traceback.

Traceback (most recent call last):
File “/home/user/frappe-bench/apps/frappe/frappe/app.py”, line 100, in application
init_request(request)
File “/home/user/frappe-bench/apps/frappe/frappe/app.py”, line 173, in init_request
frappe.init(site=site, sites_path=_sites_path, force=True)
File “/home/user/frappe-bench/apps/frappe/frappe/init.py”, line 258, in init
setup_module_map(include_all_apps=not (frappe.request or frappe.job or frappe.flags.in_migrate))
File “/home/user/frappe-bench/apps/frappe/frappe/init.py”, line 1658, in setup_module_map
for module in get_module_list(app):
File “/home/user/frappe-bench/apps/frappe/frappe/init.py”, line 1506, in get_module_list
return get_file_items(get_app_path(app_name, “modules.txt”))
File “/home/user/frappe-bench/apps/frappe/frappe/init.py”, line 1471, in get_app_path
return get_pymodule_path(app_name, *joins)
File “/home/user/frappe-bench/apps/frappe/frappe/init.py”, line 1501, in get_pymodule_path
return abspath(join(dirname(get_module(scrub(modulename)).file or “”), *joins))
File “/home/user/frappe-bench/apps/frappe/frappe/init.py”, line 1442, in get_module
return importlib.import_module(modulename)
File “/usr/lib/python3.10/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1050, in _gcd_import
File “”, line 1027, in _find_and_load
File “”, line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named ‘ui_theme’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/user/frappe-bench/apps/frappe/frappe/website/serve.py”, line 19, in get_response
endpoint, renderer_instance = path_resolver.resolve()
File “/home/user/frappe-bench/apps/frappe/frappe/website/path_resolver.py”, line 38, in resolve
resolve_redirect(self.path, request.query_string)
File “/home/user/frappe-bench/apps/frappe/frappe/website/path_resolver.py”, line 117, in resolve_redirect
redirects = frappe.get_hooks(“website_redirects”)
File “/home/user/frappe-bench/apps/frappe/frappe/init.py”, line 1607, in get_hooks
hooks = _dict(_load_app_hooks())
File “/home/user/frappe-bench/apps/frappe/frappe/utils/caching.py”, line 47, in wrapper
return func(*args, **kwargs)
File “/home/user/frappe-bench/apps/frappe/frappe/init.py”, line 1576, in _load_app_hooks
app_hooks = get_module(f"{app}.hooks")
File “/home/user/frappe-bench/apps/frappe/frappe/init.py”, line 1442, in get_module
return importlib.import_module(modulename)
File “/usr/lib/python3.10/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1050, in _gcd_import
File “”, line 1027, in _find_and_load
File “”, line 992, in _find_and_load_unlocked
File “”, line 241, in _call_with_frames_removed
File “”, line 1050, in _gcd_import
File “”, line 1027, in _find_and_load
File “”, line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named ‘ui_theme’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/user/frappe-bench/apps/frappe/frappe/middlewares.py”, line 16, in call
return super().call(environ, start_response)
File “/home/user/frappe-bench/env/lib/python3.10/site-packages/werkzeug/middleware/shared_data.py”, line 250, in call
return self.app(environ, start_response)
File “/home/user/frappe-bench/env/lib/python3.10/site-packages/werkzeug/middleware/shared_data.py”, line 250, in call
return self.app(environ, start_response)
File “/home/user/frappe-bench/apps/frappe/frappe/app.py”, line 80, in application
app(environ, start_response),
File “/home/user/frappe-bench/env/lib/python3.10/site-packages/werkzeug/wrappers/request.py”, line 190, in application
resp = f(*args[:-2] + (request,))
File “/home/user/frappe-bench/apps/frappe/frappe/app.py”, line 133, in application
response = handle_exception(e)
File “/home/user/frappe-bench/apps/frappe/frappe/permissions.py”, line 870, in wrapper
return fn(e, *args, **kwargs)
File “/home/user/frappe-bench/apps/frappe/frappe/app.py”, line 397, in handle_exception
response = get_response(“message”, http_status_code=http_status_code)
File “/home/user/frappe-bench/apps/frappe/frappe/website/serve.py”, line 23, in get_response
return handle_exception(e, endpoint, path, http_status_code)
File “/home/user/frappe-bench/apps/frappe/frappe/permissions.py”, line 870, in wrapper
return fn(e, *args, **kwargs)
File “/home/user/frappe-bench/apps/frappe/frappe/website/serve.py”, line 37, in handle_exception
return ErrorPage(exception=e).render()
File “/home/user/frappe-bench/apps/frappe/frappe/website/page_renderers/error_page.py”, line 7, in init
super().init(path=path, http_status_code=http_status_code)
File “/home/user/frappe-bench/apps/frappe/frappe/website/page_renderers/template_page.py”, line 45, in init
self.set_template_path()
File “/home/user/frappe-bench/apps/frappe/frappe/website/page_renderers/template_page.py”, line 54, in set_template_path
app_path = frappe.get_app_path(app)
File “/home/user/frappe-bench/apps/frappe/frappe/init.py”, line 1471, in get_app_path
return get_pymodule_path(app_name, *joins)
File “/home/user/frappe-bench/apps/frappe/frappe/init.py”, line 1501, in get_pymodule_path
return abspath(join(dirname(get_module(scrub(modulename)).file or “”), *joins))
File “/home/user/frappe-bench/apps/frappe/frappe/init.py”, line 1442, in get_module
return importlib.import_module(modulename)
File “/usr/lib/python3.10/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1050, in _gcd_import
File “”, line 1027, in _find_and_load
File “”, line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named ‘ui_theme’

is there a solution?

try bench restart

sorry sir but the result is still the same

 (env) user@Arentapm:~/frappe-bench/apps$ bench restart
 [sudo] password for user:
 $ sudo supervisorctl restart frappe-bench-web:
 frappe-bench-web:frappe-bench-node-socketio: stopped
 frappe-bench-web:frappe-bench-frappe-web: stopped
 frappe-bench-web:frappe-bench-frappe-web: started
 frappe-bench-web:frappe-bench-node-socketio: started
 $ sudo supervisorctl restart frappe-bench-workers:
 frappe-bench-workers:frappe-bench-frappe-schedule: stopped
 frappe-bench-workers:frappe-bench-frappe-long-worker-0: stopped
 frappe-bench-workers:frappe-bench-frappe-short-worker-0: stopped
 frappe-bench-workers:frappe-bench-frappe-schedule: started
 frappe-bench-workers:frappe-bench-frappe-short-worker-0: started
 frappe-bench-workers:frappe-bench-frappe-long-worker-0: started

Join NOW !!!

seems like earlier installed package was broken. uninstall that package and try a fresh install

hello @Ashique , I have previously tried to do it with this command

bench --site frontend uninstall-app ui_theme
bench --site frontend install-app ui_theme

can you please share the app structure

Here is the file structure of my application

(env) user@Arentapm:~/frappe-bench$ ls -R apps/ui_theme
apps/ui_theme:
README.md license.txt pyproject.toml ui_theme

apps/ui_theme/ui_theme:
init.py app.py hooks.py patches.txt templates www
pycache config modules.txt public ui_theme

apps/ui_theme/ui_theme/pycache:
init.cpython-310.pyc hooks.cpython-310.pyc

apps/ui_theme/ui_theme/config:
init.py

apps/ui_theme/ui_theme/public:
css js

apps/ui_theme/ui_theme/public/css:

apps/ui_theme/ui_theme/public/js:

apps/ui_theme/ui_theme/templates:
init.py includes pages

apps/ui_theme/ui_theme/templates/includes:

apps/ui_theme/ui_theme/templates/pages:
init.py

apps/ui_theme/ui_theme/ui_theme:
init.py pycache doctype page

apps/ui_theme/ui_theme/ui_theme/pycache:
init.cpython-310.pyc

apps/ui_theme/ui_theme/ui_theme/doctype:
init.py pycache theme_config

apps/ui_theme/ui_theme/ui_theme/doctype/pycache:
init.cpython-310.pyc

apps/ui_theme/ui_theme/ui_theme/doctype/theme_config:
pycache theme_config.json theme_config.py

apps/ui_theme/ui_theme/ui_theme/doctype/theme_config/pycache:
theme_config.cpython-310.pyc

apps/ui_theme/ui_theme/ui_theme/page:
theme_preview

apps/ui_theme/ui_theme/ui_theme/page/theme_preview:
init.py theme_preview.js

apps/ui_theme/ui_theme/www:

app structure seems fine.

lets repeat the practice once more. uninstall the current app . remove the folder itself from apps directory. clear the bench cache and all. make sure apps.txt file is clean.

get the app from your source into bench. install it in your site.
do bench migrate , build and restart.