Setting ERPNext 14 on a Fresh system is failing with error: ImportError: Module import failed for Purchase Taxes and Charges Template, the DocType you're trying to open might be deleted.<br> Error: No module named 'redis.commands'

I was not able to install dependent apps like hrms and India-complinace in the ready to use Bitnami’s VM so I installed Ubuntu server in a new VM and am installing ERPNext.

But on giving the command bench --site erp14 install-app erpnext --force I am getting following error.

Installing payments...
Updating DocTypes for payments      : [========================================] 100%
Updating Dashboard for payments

Installing erpnext...
Updating DocTypes for erpnext       : [                                        ] 1%An error occurred while installing erpnext: Module import failed for Purchase Taxes and Charges Template, the DocType you're trying to open might be deleted.<br> Error: No module named 'redis.commands'
Traceback (most recent call last):
  File "apps/frappe/frappe/modules/utils.py", line 240, in load_doctype_module
    doctype_python_modules[key] = frappe.get_module(module_name)
  File "apps/frappe/frappe/__init__.py", line 1323, 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 "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "apps/erpnext/erpnext/accounts/doctype/purchase_taxes_and_charges_template/purchase_taxes_and_charges_template.py", line 8, in <module>
    from erpnext.accounts.doctype.sales_taxes_and_charges_template.sales_taxes_and_charges_template import (
  File "apps/erpnext/erpnext/accounts/doctype/sales_taxes_and_charges_template/sales_taxes_and_charges_template.py", line 10, in <module>
    from erpnext.controllers.accounts_controller import (
  File "apps/erpnext/erpnext/controllers/accounts_controller.py", line 29, in <module>
    from erpnext.accounts.doctype.pricing_rule.utils import (
  File "apps/erpnext/erpnext/accounts/doctype/pricing_rule/utils.py", line 14, in <module>
    from erpnext.setup.doctype.item_group.item_group import get_child_item_groups
  File "apps/erpnext/erpnext/setup/doctype/item_group/item_group.py", line 14, in <module>
    from erpnext.e_commerce.doctype.e_commerce_settings.e_commerce_settings import ECommerceSettings
  File "apps/erpnext/erpnext/e_commerce/doctype/e_commerce_settings/e_commerce_settings.py", line 10, in <module>
    from erpnext.e_commerce.redisearch_utils import (
  File "apps/erpnext/erpnext/e_commerce/redisearch_utils.py", line 10, in <module>
    from redis.commands.search.field import TagField, TextField
ModuleNotFoundError: No module named 'redis.commands'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "apps/frappe/frappe/commands/site.py", line 413, in install_app
    _install_app(app, verbose=context.verbose, force=force)
  File "apps/frappe/frappe/installer.py", line 290, in install_app
    sync_for(name, force=force, reset_permissions=True)
  File "apps/frappe/frappe/model/sync.py", line 80, in sync_for
    import_file_by_path(
  File "apps/frappe/frappe/modules/import_file.py", line 145, in import_file_by_path
    import_doc(
  File "apps/frappe/frappe/modules/import_file.py", line 242, in import_doc
    doc.insert()
  File "apps/frappe/frappe/model/document.py", line 283, in insert
    self.run_post_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1089, in run_post_save_methods
    self.run_method("on_update")
  File "apps/frappe/frappe/model/document.py", line 930, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1270, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1252, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 927, in fn
    return method_object(*args, **kwargs)
  File "apps/frappe/frappe/core/doctype/doctype/doctype.py", line 404, in on_update
    self.run_module_method("on_doctype_update")
  File "apps/frappe/frappe/core/doctype/doctype/doctype.py", line 489, in run_module_method
    module = load_doctype_module(self.name, self.module)
  File "apps/frappe/frappe/modules/utils.py", line 244, in load_doctype_module
    raise ImportError(msg) from e
ImportError: Module import failed for Purchase Taxes and Charges Template, the DocType you're trying to open might be deleted.<br> Error: No module named 'redis.commands'

Regards,

1 Like

I have not been able to diagnose the problem but after I did a reboot of the VM and after reboot I issued the following commands.

export LC_ALL=C.UTF-8
bench --site erp14 install-app erpnext --force

This worked and ERPNext was installed without any error.

Then I tried to install hrms and again I faced a lot of errors so I again reboot the VM and issued following commands.

export LC_ALL=C.UTF-8
bench --site erp14 install-app hrms

And this worked!

Similarly I followed the reboot cycle step and installed india_complainace and it worked also!

Regards,

1 Like

This should not be marked as a solution as it doesn’t adequately address the actual problem and the given answer is narrow in scope.