Bench --site new-site install-app erpnext fails - IntegrityError(1062, “Duplicate entry ‘Accounts’

Having come so far, the final step fails.

LOG is below. Any thoughts. It says there is a duplicate data

erp@Satish-HP-Pavillion:~/bench/frappe-bench$ bench --site satish install-app erpnext
WARN: bench is installed in editable mode!

This is not the recommended mode of installation for production. Instead, install the package from PyPI with: pip install frappe-bench

Installing erpnext…
Traceback (most recent call last):
File “/home/erp/bench/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 320, in db_insert
frappe.db.sql(“”"INSERT INTO tab{doctype} ({columns})
File “/home/erp/bench/frappe-bench/apps/frappe/frappe/database/database.py”, line 156, in sql
self._cursor.execute(query, values)
File “/home/erp/bench/frappe-bench/env/lib/python3.8/site-packages/pymysql/cursors.py”, line 170, in execute
result = self._query(query)
File “/home/erp/bench/frappe-bench/env/lib/python3.8/site-packages/pymysql/cursors.py”, line 328, in _query
conn.query(q)
File “/home/erp/bench/frappe-bench/env/lib/python3.8/site-packages/pymysql/connections.py”, line 517, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File “/home/erp/bench/frappe-bench/env/lib/python3.8/site-packages/pymysql/connections.py”, line 732, in _read_query_result
result.read()
File “/home/erp/bench/frappe-bench/env/lib/python3.8/site-packages/pymysql/connections.py”, line 1075, in read
first_packet = self.connection._read_packet()
File “/home/erp/bench/frappe-bench/env/lib/python3.8/site-packages/pymysql/connections.py”, line 684, in _read_packet
packet.check_error()
File “/home/erp/bench/frappe-bench/env/lib/python3.8/site-packages/pymysql/protocol.py”, line 220, in check_error
err.raise_mysql_exception(self._data)
File “/home/erp/bench/frappe-bench/env/lib/python3.8/site-packages/pymysql/err.py”, line 109, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.IntegrityError: (1062, “Duplicate entry ‘Accounts’ for key ‘PRIMARY’”)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/lib/python3.8/runpy.py”, line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File “/usr/lib/python3.8/runpy.py”, line 86, in _run_code
exec(code, run_globals)
File “/home/erp/bench/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 99, in
main()
File “/home/erp/bench/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/erp/bench/frappe-bench/env/lib/python3.8/site-packages/click/core.py”, line 764, in call
return self.main(*args, **kwargs)
File “/home/erp/bench/frappe-bench/env/lib/python3.8/site-packages/click/core.py”, line 717, in main
rv = self.invoke(ctx)
File “/home/erp/bench/frappe-bench/env/lib/python3.8/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/erp/bench/frappe-bench/env/lib/python3.8/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/erp/bench/frappe-bench/env/lib/python3.8/site-packages/click/core.py”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/erp/bench/frappe-bench/env/lib/python3.8/site-packages/click/core.py”, line 555, in invoke
return callback(*args, **kwargs)
File “/home/erp/bench/frappe-bench/env/lib/python3.8/site-packages/click/decorators.py”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/erp/bench/frappe-bench/apps/frappe/frappe/commands/init.py”, line 26, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/erp/bench/frappe-bench/apps/frappe/frappe/commands/site.py”, line 203, in install_app
_install_app(app, verbose=context.verbose)
File “/home/erp/bench/frappe-bench/apps/frappe/frappe/installer.py”, line 81, in install_app
add_module_defs(name)
File “/home/erp/bench/frappe-bench/apps/frappe/frappe/installer.py”, line 278, in add_module_defs
d.save(ignore_permissions=True)
File “/home/erp/bench/frappe-bench/apps/frappe/frappe/model/document.py”, line 273, in save
return self._save(*args, **kwargs)
File “/home/erp/bench/frappe-bench/apps/frappe/frappe/model/document.py”, line 296, in _save
self.insert()
File “/home/erp/bench/frappe-bench/apps/frappe/frappe/model/document.py”, line 248, in insert
raise e
File “/home/erp/bench/frappe-bench/apps/frappe/frappe/model/document.py”, line 245, in insert
self.db_insert()
File “/home/erp/bench/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 335, in db_insert
raise frappe.DuplicateEntryError(self.doctype, self.name, e)
frappe.exceptions.DuplicateEntryError: (‘Module Def’, ‘Accounts’, IntegrityError(1062, “Duplicate entry ‘Accounts’ for key ‘PRIMARY’”))

Seems like a version difference between frappe and bench.

bench switch-to-branch master frappe erpnext
bench update --force

2 Likes

That branch is inactive, with no commits for the last year GitHub - frappe/erpnext at master

You may prefer version-12 or develop instead!

2 Likes

You are right. I saw that this was v11. I switched the command to develop.

bench switch-to-branch develop frappe erpnext