如何在安装ERPNext中的包/模块时解决重复条目错误,例如印度合规模块。

huangapple go评论55阅读模式
英文:

How to solve duplicate entry error while installing packages/modules in erpnext, eg indain_compliance module

问题

抱歉,我只能提供代码的翻译。以下是您提供的代码的翻译:

我一直在尝试在我的Ubuntu虚拟机上安装"indian_compliance"模块以便在ERPNext上使用以下终端命令

bench get-app https://github.com/resilient-tech/india-compliance.git
bench install-app india_compliance


但由于某种原因它曾经失败过,并且在home\frappe-bench\apps\indian_compliance目录中创建了一个文件夹。

然后在重试相同命令时出现了以下错误:

raise frappe.DuplicateEntryError(self.doctype, self.name, e)
frappe.exceptions.DuplicateEntryError: ('Module Def', 'GST India', IntegrityError(1062, "Duplicate entry 'GST India' for key 'PRIMARY'"))


但尝试删除文件夹后仍然收到相同的错误代码。

在此之前,我在安装ERPNext时遇到类似的错误:

Installing erpnext...
An error occurred while installing erpnext: ('Module Def', 'Accounts', IntegrityError(1062, "Duplicate entry 'Accounts' for key 'PRIMARY'"))
Traceback (most recent call last):
File "apps/frappe/frappe/model/base_document.py", line 510, in db_insert
frappe.db.sql(
File "apps/frappe/frappe/database/database.py", line 229, in sql
self._cursor.execute(query, values)
File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 158, in execute
result = self._query(query)
File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 325, in _query
conn.query(q)
File "env/lib/python3.10/site-packages/pymysql/connections.py", line 549, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File "env/lib/python3.10/site-packages/pymysql/connections.py", line 779, in _read_query_result
result.read()
File "env/lib/python3.10/site-packages/pymysql/connections.py", line 1157, in read
first_packet = self.connection._read_packet()
File "env/lib/python3.10/site-packages/pymysql/connections.py", line 729, in _read_packet
packet.raise_for_error()
File "env/lib/python3.10/site-packages/pymysql/protocol.py", line 221, in raise_for_error
err.raise_mysql_exception(self._data)
File "env/lib/python3.10/site-packages/pymysql/err.py", line 143, 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 "apps/frappe/frappe/commands/site.py", line 463, in install_app
_install_app(app, verbose=context.verbose, force=force)
File "apps/frappe/frappe/installer.py", line 291, in install_app
add_module_defs(name, ignore_if_duplicate=force)
File "apps/frappe/frappe/installer.py", line 622, in add_module_defs
d.insert(ignore_permissions=True, ignore_if_duplicate=ignore_if_duplicate)
File "apps/frappe/frappe/model/document.py", line 279, in insert
self.db_insert(ignore_if_duplicate=ignore_if_duplicate)
File "apps/frappe/frappe/model/base_document.py", line 537, 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'"))

但我找到的唯一解决方法是完全从头开始制作一个新的虚拟机!我已经多次遇到了这个错误,创建一个全新的虚拟机变得非常麻烦,肯定有一种方法可以解决这种错误,比如从MySQL数据库中删除它,但是我无法找到更多信息。

mysql -u root -p
SHOW DATABASES;
USE database_name_here;
SHOW TABLES;

接下来该怎么做,如何找到重复的条目是我无法做到的。


希望这能帮助您理解代码的翻译。如果您有任何其他问题,请随时提问。

<details>
<summary>英文:</summary>

Hey I have been trying to install indian_compliance module on my ubuntu vm for use on erpnext using the following commands in terminal:

bench get-app https://github.com/resilient-tech/india-compliance.git
bench install-app india_compliance


but it failed once for some reason and a folder got created in home\\frappe-bench\\apps\\indian_compliance

then on retrying the same command was getting this error:

raise frappe.DuplicateEntryError(self.doctype, self.name, e)
frappe.exceptions.DuplicateEntryError: ('Module Def', 'GST India', IntegrityError(1062, "Duplicate entry 'GST India' for key 'PRIMARY'"))


but then tried deleting the folder but still getting the same error code

Before this I was facing similar error while installing erpnext

Installing erpnext...
An error occurred while installing erpnext: ('Module Def', 'Accounts', IntegrityError(1062, "Duplicate entry 'Accounts' for key 'PRIMARY'"))
Traceback (most recent call last):
File "apps/frappe/frappe/model/base_document.py", line 510, in db_insert
frappe.db.sql(
File "apps/frappe/frappe/database/database.py", line 229, in sql
self._cursor.execute(query, values)
File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 158, in execute
result = self._query(query)
File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 325, in _query
conn.query(q)
File "env/lib/python3.10/site-packages/pymysql/connections.py", line 549, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File "env/lib/python3.10/site-packages/pymysql/connections.py", line 779, in _read_query_result
result.read()
File "env/lib/python3.10/site-packages/pymysql/connections.py", line 1157, in read
first_packet = self.connection._read_packet()
File "env/lib/python3.10/site-packages/pymysql/connections.py", line 729, in _read_packet
packet.raise_for_error()
File "env/lib/python3.10/site-packages/pymysql/protocol.py", line 221, in raise_for_error
err.raise_mysql_exception(self._data)
File "env/lib/python3.10/site-packages/pymysql/err.py", line 143, 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 "apps/frappe/frappe/commands/site.py", line 463, in install_app
_install_app(app, verbose=context.verbose, force=force)
File "apps/frappe/frappe/installer.py", line 291, in install_app
add_module_defs(name, ignore_if_duplicate=force)
File "apps/frappe/frappe/installer.py", line 622, in add_module_defs
d.insert(ignore_permissions=True, ignore_if_duplicate=ignore_if_duplicate)
File "apps/frappe/frappe/model/document.py", line 279, in insert
self.db_insert(ignore_if_duplicate=ignore_if_duplicate)
File "apps/frappe/frappe/model/base_document.py", line 537, 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'"))


but the only solution I found was to to make a completely new machine !! from scratch i have faced this error quite a few times and it has become a hassle to create an entire new machine again, there must be a way to solve such error, like somehow deleting it from the mysql database on the machine, but was not able to figure much out

    mysql -u root -p
    SHOW DATABASES;
    USE database_name_here;
    SHOW TABLES;
    
then what to do next how to find the duplicate entry is what i am not able to do


</details>


# 答案1
**得分**: 1

我曾经面对过类似的错误,我解决的方法是找到 MySQL 中的重复包并删除它们,在你的情况下,这个方法也应该适用。你的 MySQL 步骤实际上是正确的,首先再次按照以下步骤执行:

mysql -u root -p
SHOW DATABASES;
USE 数据库名称在这里;
SHOW TABLES;


然后执行以下操作:

SELECT * FROM tabModule Def;
DELETE FROM tabModule Def WHERE app = 'Indian Compliance';


然后安装命令应该可以运行了!

<details>
<summary>英文:</summary>

I was facing similar error, the way I solved was by finding the duplicate packages in mysql and deleting them, in your case too this should work, you mysql steps are infact correct to a point first follow them again:

    mysql -u root -p
    SHOW DATABASES;
    USE database_name_here;
    SHOW TABLES;

then 

    SELECT * FROM `tabModule Def`;
    DELETE FROM `tabModule Def` WHERE app = &#39;Indian Compliance&#39;;

then the install commands should run!!

</details>



huangapple
  • 本文由 发表于 2023年7月13日 17:42:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/76678003.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定