Export to Excel Server Error : AttributeError: ‘HTML2Text’ object has no attribute ‘unescape’

In Gross profit report, when I try to Export to Excel, specially when flitered to “Group by Item Code”:
image
I get a server error with this text:
Traceback (most recent call last):
File “/opt/bench/erpnext/apps/frappe/frappe/app.py”, line 65, in application
response = frappe.handler.handle()
File “/opt/bench/erpnext/apps/frappe/frappe/handler.py”, line 31, in handle
data = execute_cmd(cmd)
File “/opt/bench/erpnext/apps/frappe/frappe/handler.py”, line 67, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “/opt/bench/erpnext/apps/frappe/frappe/init.py”, line 1198, in call
return fn(*args, **newargs)
File “/opt/bench/erpnext/apps/frappe/frappe/desk/query_report.py”, line 358, in export_query
xlsx_file = make_xlsx(xlsx_data, “Query Report”, column_widths=column_widths)
File “/opt/bench/erpnext/apps/frappe/frappe/utils/xlsxutils.py”, line 36, in make_xlsx
value = handle_html(item)
File “/opt/bench/erpnext/apps/frappe/frappe/utils/xlsxutils.py”, line 66, in handle_html
h = h.unescape(data or “”)
AttributeError: ‘HTML2Text’ object has no attribute ‘unescape’

I got a similar erorr when using data import tool and downloading a template.
ERPNext: v13.x.x-develop () (develop)
Frappe Framework: v13.x.x-develop () (develop)

Traceback (most recent call last):
File “/home/frappe/erpnext/apps/frappe/frappe/app.py”, line 68, in application
response = frappe.api.handle()
File “/home/frappe/erpnext/apps/frappe/frappe/api.py”, line 54, in handle
return frappe.handler.handle()
File “/home/frappe/erpnext/apps/frappe/frappe/handler.py”, line 31, in handle
data = execute_cmd(cmd)
File “/home/frappe/erpnext/apps/frappe/frappe/handler.py”, line 67, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “/home/frappe/erpnext/apps/frappe/frappe/init.py”, line 1168, in call
return fn(*args, **newargs)
File “/home/frappe/erpnext/apps/frappe/frappe/core/doctype/data_import/data_import.py”, line 140, in download_template
e.build_response()
File “/home/frappe/erpnext/apps/frappe/frappe/core/doctype/data_import/exporter.py”, line 253, in build_response
self.build_xlsx_response()
File “/home/frappe/erpnext/apps/frappe/frappe/core/doctype/data_import/exporter.py”, line 259, in build_xlsx_response
build_xlsx_response(self.get_csv_array_for_export(), self.doctype)
File “/home/frappe/erpnext/apps/frappe/frappe/utils/xlsxutils.py”, line 118, in build_xlsx_response
xlsx_file = make_xlsx(data, filename)
File “/home/frappe/erpnext/apps/frappe/frappe/utils/xlsxutils.py”, line 36, in make_xlsx
value = handle_html(item)
File “/home/frappe/erpnext/apps/frappe/frappe/utils/xlsxutils.py”, line 66, in handle_html
h = h.unescape(data or “”)
AttributeError: ‘HTML2Text’ object has no attribute ‘unescape’

I couldn’t find a solution for it.
What I did was:
Create a new clean VPS,
Install V13 (not develop)
export and import the database with files to the new server, and the errors where gone.

fixed on develop version too: fix: unknown method unescape on html2text by ankush · Pull Request #15796 · frappe/frappe · GitHub

1 Like