ImportError: Module import failed for Tax Rule (erpnext.accounts.doctype.tax_rule.tax_rule)

Hi Team,

While installing erpnext 8.7.2 version i am getting error

$ bench --site client.local install-app erpnext
Installing erpnext…
Traceback (most recent call last):
File “/usr/lib/python2.7/runpy.py”, line 174, in _run_module_as_main
main”, fname, loader, pkg_name)
File “/usr/lib/python2.7/runpy.py”, line 72, in _run_code
exec code in run_globals
File “/home/sushmitha/client-bench/apps/frappe/frappe/utils/bench_helper.py”, line 79, in
main()
File “/home/sushmitha/client-bench/apps/frappe/frappe/utils/bench_helper.py”, line 16, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/sushmitha/client-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 722, in call
return self.main(*args, **kwargs)
File “/home/sushmitha/client-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/home/sushmitha/client-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/sushmitha/client-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/sushmitha/client-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/sushmitha/client-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 535, in invoke
return callback(*args, **kwargs)
File “/home/sushmitha/client-bench/env/local/lib/python2.7/site-packages/click/decorators.py”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/sushmitha/client-bench/apps/frappe/frappe/commands/init.py”, line 24, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/sushmitha/client-bench/apps/frappe/frappe/commands/site.py”, line 157, in install_app
_install_app(app, verbose=context.verbose)
File “/home/sushmitha/client-bench/apps/frappe/frappe/installer.py”, line 138, in install_app
add_module_defs(name)
File “/home/sushmitha/client-bench/apps/frappe/frappe/installer.py”, line 334, in add_module_defs
d.save(ignore_permissions=True)
File “/home/sushmitha/client-bench/apps/frappe/frappe/model/document.py”, line 230, in save
return self._save(*args, **kwargs)
File “/home/sushmitha/client-bench/apps/frappe/frappe/model/document.py”, line 253, in _save
self.insert()
File “/home/sushmitha/client-bench/apps/frappe/frappe/model/document.py”, line 207, in insert
raise e
frappe.exceptions.DuplicateEntryError: (u’Module Def’, u’Accounts’, IntegrityError(1062, “Duplicate entry ‘Accounts’ for key ‘PRIMARY’”))

Added this lines in site_config.json

“dropbox_access_key”: “ACCESSKEY”,
“dropbox_secret_key”: “SECRECTKEY”,
“developer_mode”:1

I reinstalled the site
After then when i install the erpnext i am getting this error.

$ bench --site client.local install-app erpnext
Installing erpnext…
Updating DocTypes for erpnext : [ ]Traceback (most recent call last):
File “/usr/lib/python2.7/runpy.py”, line 174, in _run_module_as_main
main”, fname, loader, pkg_name)
File “/usr/lib/python2.7/runpy.py”, line 72, in _run_code
exec code in run_globals
File “/home/sushmitha/client-bench/apps/frappe/frappe/utils/bench_helper.py”, line 79, in
main()
File “/home/sushmitha/client-bench/apps/frappe/frappe/utils/bench_helper.py”, line 16, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/sushmitha/client-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 722, in call
return self.main(*args, **kwargs)
File “/home/sushmitha/client-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/home/sushmitha/client-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/sushmitha/client-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/sushmitha/client-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/sushmitha/client-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 535, in invoke
return callback(*args, **kwargs)
File “/home/sushmitha/client-bench/env/local/lib/python2.7/site-packages/click/decorators.py”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/sushmitha/client-bench/apps/frappe/frappe/commands/init.py”, line 24, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/sushmitha/client-bench/apps/frappe/frappe/commands/site.py”, line 157, in install_app
_install_app(app, verbose=context.verbose)
File “/home/sushmitha/client-bench/apps/frappe/frappe/installer.py”, line 140, in install_app
sync_for(name, force=True, sync_everything=True, verbose=verbose, reset_permissions=True)
File “/home/sushmitha/client-bench/apps/frappe/frappe/model/sync.py”, line 45, in sync_for
reset_permissions=reset_permissions)
File “/home/sushmitha/client-bench/apps/frappe/frappe/modules/import_file.py”, line 58, in import_file_by_path
ignore_version=ignore_version, reset_permissions=reset_permissions)
File “/home/sushmitha/client-bench/apps/frappe/frappe/modules/import_file.py”, line 129, in import_doc
doc.insert()
File “/home/sushmitha/client-bench/apps/frappe/frappe/model/document.py”, line 219, in insert
self.run_post_save_methods()
File “/home/sushmitha/client-bench/apps/frappe/frappe/model/document.py”, line 790, in run_post_save_methods
self.run_method(“on_update”)
File “/home/sushmitha/client-bench/apps/frappe/frappe/model/document.py”, line 666, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/sushmitha/client-bench/apps/frappe/frappe/model/document.py”, line 892, in composer
return composed(self, method, *args, **kwargs)
File “/home/sushmitha/client-bench/apps/frappe/frappe/model/document.py”, line 875, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/sushmitha/client-bench/apps/frappe/frappe/model/document.py”, line 660, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/sushmitha/client-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py”, line 208, in on_update
self.run_module_method(“on_doctype_update”)
File “/home/sushmitha/client-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py”, line 257, in run_module_method
module = load_doctype_module(self.name, self.module)
File “/home/sushmitha/client-bench/apps/frappe/frappe/modules/utils.py”, line 183, in load_doctype_module
raise ImportError, ‘Module import failed for {0} ({1})’.format(doctype, module_name)
ImportError: Module import failed for Tax Rule (erpnext.accounts.doctype.tax_rule.tax_rule)

Hi Team,

Any update on this ?

Thanks&Regards
Vivekananda reddy

it seems the ERPNext is already installed, try to reinstall the site using
bench --site sitename reinstall command

Hi Makarand,

we solved that issue by doing site reinstall, now we are getting this error.

raise ImportError, ‘Module import failed for {0} ({1})’.format(doctype, module_name)
ImportError: Module import failed for Tax Rule (erpnext.accounts.doctype.tax_rule.tax_rule)

can you give solution for this?

Thanks&Regards
Vivekananda reddy

Have you modified the code of tax_rule.py? Sometime module import fails due to wrong import statement/ circular import inside py file.

Hi Nabinhait,

No we are doing a fresh installation of erpnext on ubuntu 14.04 .
when i am trying to installe erpnext app , i am getting this error.

Thanks&Regards
Vivekananda reddy