Error while installing erpnext in new instance

Hello guys,
While installing erpnext i am getting the following error.

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/erpnext/darlat/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 79, in
main()
File “/home/erpnext/darlat/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 16, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/erpnext/darlat/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 722, in call
return self.main(*args, **kwargs)
File “/home/erpnext/darlat/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/home/erpnext/darlat/frappe-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/erpnext/darlat/frappe-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/erpnext/darlat/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/erpnext/darlat/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 535, in invoke
return callback(*args, **kwargs)
File “/home/erpnext/darlat/frappe-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/erpnext/darlat/frappe-bench/apps/frappe/frappe/commands/init.py”, line 24, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/erpnext/darlat/frappe-bench/apps/frappe/frappe/commands/site.py”, line 157, in install_app
_install_app(app, verbose=context.verbose)
File “/home/erpnext/darlat/frappe-bench/apps/frappe/frappe/installer.py”, line 138, in install_app
add_module_defs(name)
File “/home/erpnext/darlat/frappe-bench/apps/frappe/frappe/installer.py”, line 334, in add_module_defs
d.save(ignore_permissions=True)
File “/home/erpnext/darlat/frappe-bench/apps/frappe/frappe/model/document.py”, line 230, in save
return self._save(*args, **kwargs)
File “/home/erpnext/darlat/frappe-bench/apps/frappe/frappe/model/document.py”, line 253, in _save
self.insert()
File “/home/erpnext/darlat/frappe-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’”))

Please help me to resolve this error while installing erpnext.
Thanks

Works okay for me. Can you share the steps to reproduce?

@rmehta Thanks for the reply. When i am trying to install erpnext using this command

bench install-app erpnext

the following error occurs

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/erpnext/darlat/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 79, in
main()
File “/home/erpnext/darlat/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 16, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/erpnext/darlat/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 722, in call
return self.main(*args, **kwargs)
File “/home/erpnext/darlat/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/home/erpnext/darlat/frappe-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/erpnext/darlat/frappe-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/erpnext/darlat/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/erpnext/darlat/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 535, in invoke
return callback(*args, **kwargs)
File “/home/erpnext/darlat/frappe-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/erpnext/darlat/frappe-bench/apps/frappe/frappe/commands/init.py”, line 24, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/erpnext/darlat/frappe-bench/apps/frappe/frappe/commands/site.py”, line 157, in install_app
_install_app(app, verbose=context.verbose)
File “/home/erpnext/darlat/frappe-bench/apps/frappe/frappe/installer.py”, line 138, in install_app
add_module_defs(name)
File “/home/erpnext/darlat/frappe-bench/apps/frappe/frappe/installer.py”, line 334, in add_module_defs
d.save(ignore_permissions=True)
File “/home/erpnext/darlat/frappe-bench/apps/frappe/frappe/model/document.py”, line 230, in save
return self._save(*args, **kwargs)
File “/home/erpnext/darlat/frappe-bench/apps/frappe/frappe/model/document.py”, line 253, in _save
self.insert()
File “/home/erpnext/darlat/frappe-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’”))

@rmehta when i tried to create another new instance and while installing erpnext using following command

bench install-app erpnext

The below error is showing.

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/erpnext/daral/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 79, in
main()
File “/home/erpnext/daral/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 16, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/erpnext/daral/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 722, in call
return self.main(*args, **kwargs)
File “/home/erpnext/daral/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/home/erpnext/daral/frappe-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/erpnext/daral/frappe-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/erpnext/daral/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/erpnext/daral/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 535, in invoke
return callback(*args, **kwargs)
File “/home/erpnext/daral/frappe-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/erpnext/daral/frappe-bench/apps/frappe/frappe/commands/init.py”, line 24, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/erpnext/daral/frappe-bench/apps/frappe/frappe/commands/site.py”, line 157, in install_app
_install_app(app, verbose=context.verbose)
File “/home/erpnext/daral/frappe-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/erpnext/daral/frappe-bench/apps/frappe/frappe/model/sync.py”, line 45, in sync_for
reset_permissions=reset_permissions)
File “/home/erpnext/daral/frappe-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/erpnext/daral/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 129, in import_doc
doc.insert()
File “/home/erpnext/daral/frappe-bench/apps/frappe/frappe/model/document.py”, line 219, in insert
self.run_post_save_methods()
File “/home/erpnext/daral/frappe-bench/apps/frappe/frappe/model/document.py”, line 790, in run_post_save_methods
self.run_method(“on_update”)
File “/home/erpnext/daral/frappe-bench/apps/frappe/frappe/model/document.py”, line 666, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/erpnext/daral/frappe-bench/apps/frappe/frappe/model/document.py”, line 892, in composer
return composed(self, method, *args, **kwargs)
File “/home/erpnext/daral/frappe-bench/apps/frappe/frappe/model/document.py”, line 875, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/erpnext/daral/frappe-bench/apps/frappe/frappe/model/document.py”, line 660, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/erpnext/daral/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py”, line 208, in on_update
self.run_module_method(“on_doctype_update”)
File “/home/erpnext/daral/frappe-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/erpnext/daral/frappe-bench/apps/frappe/frappe/modules/utils.py”, line 184, in load_doctype_module
raise ImportError, ‘Module import failed for {0} ({1})’.format(doctype, module_name)
ImportError: Module import failed for Payment Request (erpnext.accounts.doctype.payment_request.payment_request)

Try this command after creating a new site, bench --site [your site-name] install-app erpnext because there is a good chance that when you are using bench install-app erpnext, its installing the app on the previous instance instead of the new one unless ofcourse you have used bench use [new site-name] to get on to the new instance.

@shreya115 Thanks for the reply but i tried as you mentioned

bench --site [your site-name] install-app erpnext

but again the same error occurs

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/erpnext/daralatta/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 79, in
main()
File “/home/erpnext/daralatta/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 16, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/erpnext/daralatta/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 722, in call
return self.main(*args, **kwargs)
File “/home/erpnext/daralatta/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/home/erpnext/daralatta/frappe-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/erpnext/daralatta/frappe-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/erpnext/daralatta/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/erpnext/daralatta/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 535, in invoke
return callback(*args, **kwargs)
File “/home/erpnext/daralatta/frappe-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/erpnext/daralatta/frappe-bench/apps/frappe/frappe/commands/init.py”, line 24, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/erpnext/daralatta/frappe-bench/apps/frappe/frappe/commands/site.py”, line 157, in install_app
_install_app(app, verbose=context.verbose)
File “/home/erpnext/daralatta/frappe-bench/apps/frappe/frappe/installer.py”, line 138, in install_app
add_module_defs(name)
File “/home/erpnext/daralatta/frappe-bench/apps/frappe/frappe/installer.py”, line 334, in add_module_defs
d.save(ignore_permissions=True)
File “/home/erpnext/daralatta/frappe-bench/apps/frappe/frappe/model/document.py”, line 230, in save
return self._save(*args, **kwargs)
File “/home/erpnext/daralatta/frappe-bench/apps/frappe/frappe/model/document.py”, line 253, in _save
self.insert()
File “/home/erpnext/daralatta/frappe-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’”))

Did you try this on your new site? Maybe the app is already installed. Try uninstalling the app and install it again on a fresh site bench uninstall-app erpnext

@shreya115 yes I tried on a new site. But now i am not able to uninstall the app while running the following command

bench uninstall-app erpnext

I am getting the following error in my terminal

All doctypes (including custom), modules related to this app will be deleted. Are you sure you want to continue (y/n) ? y
Backing up…
removing DocType Payment Request…
removing DocType Sales Invoice Item…
removing DocType Cost Center…
removing DocType Account…
removing DocType Tax Rule…
removing DocType Depreciation Schedule…
removing DocType Bank Reconciliation Detail…
removing DocType Asset Category…
removing DocType Period Closing Voucher…
removing DocType Sales Taxes and Charges Template…
removing DocType Shipping Rule…
removing DocType Sales Invoice Timesheet…
removing DocType Journal Entry Account…
removing DocType Sales Invoice Payment…
removing DocType Payment Reconciliation Invoice…
removing DocType Payment Entry Deduction…
removing DocType Party Account…
removing DocType Cheque Print Template…
removing Module Accounts…
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/erpnext/daralatta/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 79, in
main()
File “/home/erpnext/daralatta/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 16, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/erpnext/daralatta/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 722, in call
return self.main(*args, **kwargs)
File “/home/erpnext/daralatta/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/home/erpnext/daralatta/frappe-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/erpnext/daralatta/frappe-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/erpnext/daralatta/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/erpnext/daralatta/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 535, in invoke
return callback(*args, **kwargs)
File “/home/erpnext/daralatta/frappe-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/erpnext/daralatta/frappe-bench/apps/frappe/frappe/commands/init.py”, line 24, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/erpnext/daralatta/frappe-bench/apps/frappe/frappe/commands/site.py”, line 320, in uninstall
remove_app(app, dry_run, yes)
File “/home/erpnext/daralatta/frappe-bench/apps/frappe/frappe/installer.py”, line 211, in remove_app
frappe.delete_doc(“Module Def”, module_name)
File “/home/erpnext/daralatta/frappe-bench/apps/frappe/frappe/init.py”, line 641, in delete_doc
ignore_permissions, flags)
File “/home/erpnext/daralatta/frappe-bench/apps/frappe/frappe/model/delete_doc.py”, line 78, in delete_doc
async=False if frappe.flags.in_test else True)
File “/home/erpnext/daralatta/frappe-bench/apps/frappe/frappe/init.py”, line 1298, in enqueue
return frappe.utils.background_jobs.enqueue(*args, **kwargs)
File “/home/erpnext/daralatta/frappe-bench/apps/frappe/frappe/utils/background_jobs.py”, line 46, in enqueue
“kwargs”: kwargs
File “/home/erpnext/daralatta/frappe-bench/env/local/lib/python2.7/site-packages/rq/queue.py”, line 252, in enqueue_call
job = self.enqueue_job(job, at_front=at_front)
File “/home/erpnext/daralatta/frappe-bench/env/local/lib/python2.7/site-packages/rq/queue.py”, line 325, in enqueue_job
pipe.execute()
File “/home/erpnext/daralatta/frappe-bench/env/local/lib/python2.7/site-packages/redis/client.py”, line 2894, in execute
return execute(conn, stack, raise_on_error)
File “/home/erpnext/daralatta/frappe-bench/env/local/lib/python2.7/site-packages/redis/client.py”, line 2749, in _execute_transaction
connection.send_packed_command(all_cmds)
File “/home/erpnext/daralatta/frappe-bench/env/local/lib/python2.7/site-packages/redis/connection.py”, line 585, in send_packed_command
self.connect()
File “/home/erpnext/daralatta/frappe-bench/env/local/lib/python2.7/site-packages/redis/connection.py”, line 489, in connect
raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 111 connecting to localhost:11000. Connection refused.