Doctype error when installing Healthcare app on site

I have been following this tutorial by Karani on installing a custom app on a running ERPNext instance installed via Docker: Installing A Custom App On Your Running ERPNext Instance Installed via Docker - Code with Karani

But when I try to install the app on my site (this part of the video: https://youtu.be/BsV9ZB4Aqew?t=370) I get this error:

frappe@eebf260dc785:~/frappe-bench$ bench --site kiambu install-app healthcare
App erpnext already installed

Installing healthcare…
An error occurred while installing healthcare: Module import failed for Medical Department, the DocType you’re trying to open might be deleted.
Error: No module named ‘frappe.core.doctype.medical_department’
Traceback with variables (most recent call last):
File “apps/frappe/frappe/commands/site.py”, line 444, in install_app
_install_app(app, verbose=context.verbose, force=force)
context = {‘sites’: [‘kiambu’], ‘force’: False, ‘verbose’: False, ‘profile’: False}
apps = (‘healthcare’,)
force = False
_install_app = <function install_app at 0x7f2de2815a80>
filelock = <function filelock at 0x7f2de2806ca0>
exit_code = 0
site = ‘kiambu’
app = ‘healthcare’
err = ImportError(“Module import failed for Medical Department, the DocType you’re trying to open might be deleted.
Error: No module named ‘frappe.core.doctype.medical_department’”)
File “apps/frappe/frappe/installer.py”, line 311, in install_app
frappe.get_attr(after_install)()
name = ‘healthcare’
verbose = False
set_as_patched = True
force = False
sync_jobs = <function sync_jobs at 0x7f2de12bd3a0>
sync_for = <function sync_for at 0x7f2de12be3e0>
sync_customizations = <function sync_customizations at 0x7f2de27af600>
sync_fixtures = <function sync_fixtures at 0x7f2de12be5c0>
app_hooks = {‘after_install’: [‘healthcare.setup.setup_healthcare’], ‘after_uninstall’: [‘healthcare.uninstall.after_uninstall’], ‘app_color’: [‘grey’], ‘app_description’: [‘Modern, Open Source HIS built on Frappe and ERPNext’], ‘app_email’: [‘info@earthianslive.com’], ‘app_icon’: [‘octicon octicon-file-directory’], ‘app_include_js’: [‘healthcare.bundle.js’], ‘app_license’: [‘GNU GPL V3’], ‘app_name’: [‘healthcare’], ‘app_publisher’: [‘earthians Health Informatics Pvt. Ltd.’], ‘app_title’: [‘Frappe Health’], ‘app_version’: [‘15.0.0’], ‘auto_cancel_exempted_doctypes’: [‘Inpatient Medication Entry’], ‘before_tests’: [‘healthcare.healthcare.utils.before_tests’], ‘before_uninstall’: [‘healthcare.uninstall.before_uninstall’], ‘doc_events’: {‘*’: {‘on_submit’: [‘healthcare.healthcare.doctype.patient_history_settings.patient_history_settings.create_medical_record’], ‘on_cancel’: [‘healthcare.healthcare.doctype.patient_history_settings.patient_history_settings.delete_medical_record’], 'on_update_after_sub…
installed_apps = [‘frappe’, ‘erpnext’]
app = ‘erpnext’
required_app = ‘erpnext’
after_install = ‘healthcare.setup.setup_healthcare’
File “apps/healthcare/healthcare/setup.py”, line 144, in setup_healthcare
create_custom_records()
abdm_setup = <function setup at 0x7f2ddf08b2e0>
File “apps/healthcare/healthcare/setup.py”, line 198, in create_custom_records
create_medical_departments()
File “apps/healthcare/healthcare/setup.py”, line 238, in create_medical_departments
mediacal_department = frappe.new_doc(“Medical Department”)
departments = [‘Accident And Emergency Care’, ‘Anaesthetics’, ‘Biochemistry’, ‘Cardiology’, ‘Diabetology’, ‘Dermatology’, ‘Diagnostic Imaging’, ‘ENT’, ‘Gastroenterology’, ‘General Surgery’, ‘Gynaecology’, ‘Haematology’, ‘Maternity’, ‘Microbiology’, ‘Nephrology’, ‘Neurology’, ‘Oncology’, ‘Orthopaedics’, ‘Pathology’, ‘Physiotherapy’, ‘Rheumatology’, ‘Serology’, ‘Urology’]
department = ‘Accident And Emergency Care’
File “apps/frappe/frappe/init.py”, line 1143, in new_doc
new_doc = get_new_doc(doctype, parent_doc, parentfield, as_dict=as_dict)
doctype = ‘Medical Department’
parent_doc = None
parentfield = None
as_dict = False
kwargs = {}
get_new_doc = <function get_new_doc at 0x7f2ddf5216c0>
File “apps/frappe/frappe/model/create_new.py”, line 22, in get_new_doc
frappe.local.new_doc_templates[doctype] = make_new_doc(doctype)
doctype = ‘Medical Department’
parent_doc = None
parentfield = None
as_dict = False
File “apps/frappe/frappe/model/create_new.py”, line 35, in make_new_doc
doc = frappe.get_doc({“doctype”: doctype, “__islocal”: 1, “owner”: frappe.session.user, “docstatus”: 0})
doctype = ‘Medical Department’
File “apps/frappe/frappe/init.py”, line 1286, in get_doc
doc = frappe.model.document.get_doc(*args, **kwargs)
args = ({‘doctype’: ‘Medical Department’, ‘__islocal’: 1, ‘owner’: ‘Administrator’, ‘docstatus’: 0},)
kwargs = {}
frappe = <module ‘frappe’ from ‘apps/frappe/frappe/init.py’>
File “apps/frappe/frappe/model/document.py”, line 83, in get_doc
controller = get_controller(doctype)
args = ({‘doctype’: ‘Medical Department’, ‘__islocal’: 1, ‘owner’: ‘Administrator’, ‘docstatus’: 0},)
kwargs = {‘doctype’: ‘Medical Department’, ‘__islocal’: 1, ‘owner’: ‘Administrator’, ‘docstatus’: 0}
doctype = ‘Medical Department’
File “apps/frappe/frappe/model/base_document.py”, line 70, in get_controller
site_controllers[doctype] = import_controller(doctype)
doctype = ‘Medical Department’
site_controllers = {‘Module Def’: <class ‘frappe.core.doctype.module_def.module_def.ModuleDef’>, ‘DocField’: <class ‘frappe.core.doctype.docfield.docfield.DocField’>, ‘DocPerm’: <class ‘frappe.core.doctype.docperm.docperm.DocPerm’>, ‘DocType Link’: <class ‘frappe.core.doctype.doctype_link.doctype_link.DocTypeLink’>, ‘System Settings’: <class ‘frappe.core.doctype.system_settings.system_settings.SystemSettings’>, ‘Notification Settings’: <class ‘frappe.desk.doctype.notification_settings.notification_settings.NotificationSettings’>, ‘DefaultValue’: <class ‘frappe.core.doctype.defaultvalue.defaultvalue.DefaultValue’>, ‘Payment Reconciliation’: <class ‘erpnext.accounts.doctype.payment_reconciliation.payment_reconciliation.PaymentReconciliation’>, ‘Customize Form’: <class ‘frappe.custom.doctype.customize_form.customize_form.CustomizeForm’>, ‘DocType Action’: <class ‘frappe.core.doctype.doctype_action.doctype_action.DocTypeAction’>, ‘DocType State’: <class 'frappe.core.doctype.doctype_state.doctype_state.DocTyp…
File “apps/frappe/frappe/model/base_document.py”, line 95, in import_controller
module = load_doctype_module(doctype, module_name)
doctype = ‘Medical Department’
Document = <class ‘frappe.model.document.Document’>
NestedSet = <class ‘frappe.utils.nestedset.NestedSet’>
module_name = ‘Core’
doctype_info = None
module_path = None
class_overrides = {‘Address’: [‘erpnext.accounts.custom.address.ERPNextAddress’], ‘Sales Invoice’: [‘healthcare.healthcare.custom_doctype.sales_invoice.HealthcareSalesInvoice’]}
File “apps/frappe/frappe/modules/utils.py”, line 241, in load_doctype_module
raise ImportError(msg) from e
doctype = ‘Medical Department’
module = ‘Core’
prefix = ‘’
suffix = ‘’
app = ‘frappe’
key = ********
module_name = ‘frappe.core.doctype.medical_department.medical_department’
msg = “Module import failed for Medical Department, the DocType you’re trying to open might be deleted.
Error: No module named ‘frappe.core.doctype.medical_department’”
builtins.ImportError: Module import failed for Medical Department, the DocType you’re trying to open might be deleted.
Error: No module named ‘frappe.core.doctype.medical_department’

How can I resolve this issue?

Just give this a try once

bench --site [yoursitename] uninstall-app healthcare
bench --site[yoursitename] install-app healthcare

When I run any of the two commands you have provided, I get this error now:

frappe@42c8e78194f6:~/frappe-bench$ bench --site kiambu uninstall-app healthcare
Could not find app “healthcare”:
No module named ‘healthcare’
Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/caching.py”, line 55, in wrapper
return frappe.local.request_cache[func][args_key]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
KeyError: 3761029843402468376

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 1157, in call
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py”, line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File “/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py”, line 1688, 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 1688, 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 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py”, line 783, 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/site.py”, line 962, in uninstall
remove_app(app_name=app, dry_run=dry_run, yes=yes, no_backup=no_backup, force=force)
File “/home/frappe/frappe-bench/apps/frappe/frappe/installer.py”, line 354, in remove_app
app_hooks = frappe.get_hooks(app_name=app_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 1591, in get_hooks
hooks = _dict(_load_app_hooks(app_name))
^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/caching.py”, line 57, in wrapper
return_val = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 1563, in _load_app_hooks
app_hooks = get_module(f"{app}.hooks")
^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 1429, 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 ‘healthcare’

How can I resolve the issue taking into account this new information?

I resolved this issue by deleting the Healthcare app entry on the sites/apps.json file

Docker exec into the container:

docker exec -it container_id /bin/bash

Note: You should exec into the backend container and not the other containers running.

Open the apps.json file using Vim and delete the Healthcare app entry:

vim sites/apps.json

To close the file and save the changes on Vim, press the Esc button, the save the changes and exit by typing :wq and press Enter