ImportError: cannot import name ‘HeaderWriteError’ from
Such a whole frappe erpnext does not come.
Double-check the module or file where HeaderWriteError
is supposed to be defined.
If you’re using custom code or modules, ensure that these are correctly configured and that no conflicting code is affecting the import.
@Manish_Kumar run this command
bench setup requirements --python
bench build
bench migrate
bench restart
1 Like
This is server dependency pkg issue
File "env/lib/python3.10/site-packages/googleapiclient/discovery.py", line 35, in <module>
from email.generator import BytesGenerator
File "/usr/lib/python3.10/email/generator.py", line 17, in <module>
from email.errors import HeaderWriteError
ImportError: cannot import name 'HeaderWriteError' from 'email.errors' (/usr/lib/python3.10/email/errors.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "apps/frappe/frappe/app.py", line 97, in application
response = frappe.api.handle()
File "apps/frappe/frappe/api.py", line 55, in handle
return frappe.handler.handle()
File "apps/frappe/frappe/handler.py", line 48, in handle
data = execute_cmd(cmd)
File "apps/frappe/frappe/handler.py", line 86, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File "apps/frappe/frappe/__init__.py", line 1619, in call
return fn(*args, **newargs)
File "apps/frappe/frappe/client.py", line 232, in save
doc.save()
File "apps/frappe/frappe/model/document.py", line 310, in save
return self._save(*args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 332, in _save
return self.insert()
File "apps/frappe/frappe/model/document.py", line 292, in insert
self.run_post_save_methods()
File "apps/frappe/frappe/model/document.py", line 1098, in run_post_save_methods
self.run_method("on_update")
File "apps/frappe/frappe/model/document.py", line 931, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 1283, in composer
return composed(self, method, *args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 1265, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File "apps/frappe/frappe/model/document.py", line 928, in fn
return method_object(*args, **kwargs)
File "apps/erpnext/erpnext/selling/doctype/customer/customer.py", line 164, in on_update
self.create_primary_contact()
File "apps/erpnext/erpnext/selling/doctype/customer/customer.py", line 186, in create_primary_contact
contact = make_contact(self)
File "apps/erpnext/erpnext/selling/doctype/customer/customer.py", line 720, in make_contact
contact.insert(ignore_permissions=flags.get("ignore_permissions"))
File "apps/frappe/frappe/model/document.py", line 282, in insert
self.run_method("after_insert")
File "apps/frappe/frappe/model/document.py", line 931, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 1280, in composer
hooks.append(frappe.get_attr(handler))
File "apps/frappe/frappe/__init__.py", line 1609, in get_attr
return getattr(get_module(modulename), methodname)
File "apps/frappe/frappe/__init__.py", line 1343, in get_module
return importlib.import_module(modulename)
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "apps/frappe/frappe/integrations/doctype/google_contacts/google_contacts.py", line 11, in <module>
from frappe.integrations.google_oauth import GoogleOAuth
File "apps/frappe/frappe/integrations/google_oauth.py", line 4, in <module>
from googleapiclient.discovery import build
File "env/lib/python3.10/site-packages/googleapiclient/discovery.py", line 37, in <module>
from email.generator import Generator as BytesGenerator
File "/usr/lib/python3.10/email/generator.py", line 17, in <module>
from email.errors import HeaderWriteError
ImportError: cannot import name 'HeaderWriteError' from 'email.errors' (/usr/lib/python3.10/email/errors.py)
looks like everyone have unattended upgrade enabled
Documented upstream:
Hello,
Temporary solution is to comment out this line
from frappe.integrations.google_oauth import GoogleOAuth