ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Local variable 'doctype' referenced before assignment


HI all! I have problems when import articles in erpnext.
I use the downloaded template for import.
But when start import i receive for each raw the error : " local variable ‘doctype’ referenced before assignment "

Here the traceback, this is identical for each row:

Traceback (most recent call last):
  File "/home/frappe/benches/bench-2018-07-31/apps/frappe/frappe/core/doctype/data_import/", line 392, in upload
    doc = frappe.get_doc(doc)
  File "/home/frappe/benches/bench-2018-07-31/apps/frappe/frappe/", line 638, in get_doc
    return frappe.model.document.get_doc(*args, **kwargs)
  File "/home/frappe/benches/bench-2018-07-31/apps/frappe/frappe/model/", line 66, in get_doc
    controller = get_controller(doctype)
UnboundLocalError: local variable 'doctype' referenced before assignment

Someone could help me?


I have got the same problem while importing Suppliers. My files seems ok to me. Other import like address are funtioning.


Did you solved this ? I have same error for another doctype.

ERPNext: v11.1.25 (master)
Frappe Framework: v11.1.26 (master)


I solved it. I was trying to import data, but I was using a template from a data export tool, where is also ID field (i removed IDs, but column was still here and was causing problem)