Pulling email UnicodeDecodeError: 'ascii' codec can't decode

Hi,

I am trying to figure out, why pulling emails is not working properly in my installation, now weeks after, I think I figured it out.

a “tail -f /home/frappe/frappe-bench/logs/worker.error.log” gave me that output:

14:36:03 short: frappe.utils.background_jobs.execute_job(event=u'all', is_async=True, job_name=u'pull_from_email_account|ISI Eingang', kwargs={'email_account': u'ISI Eingang'}, method=<function pull_from_email_account at 0x7f0ce550fb18>, site=u'autlvfil01.billa.co.at', user=u'Administrator') (4dfd1611-f014-496d-b8a2-520d16731286)
14:36:03 UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 10: ordinal not in range(128)
Traceback (most recent call last):
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/rq/worker.py", line 793, in perform_job
    rv = job.perform()
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/rq/job.py", line 599, in perform
    self._result = self._execute()
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/rq/job.py", line 605, in _execute
    return self.func(*self.args, **self.kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/background_jobs.py", line 102, in execute_job
    method(**kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 736, in pull_from_email_account
    email_account.receive()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 299, in receive
    communication.notify(attachments=attachments, fetched_from_email_account=True)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/communication.py", line 204, in notify
    fetched_from_email_account)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/email.py", line 127, in notify
    fetched_from_email_account=fetched_from_email_account)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/email.py", line 212, in get_recipients_cc_and_bcc
    cc = get_cc(doc, recipients, fetched_from_email_account=fetched_from_email_account)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/email.py", line 356, in get_cc
    cc.append(get_owner_email(doc))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/email.py", line 459, in get_owner_email
    return get_formatted_email(owner) or owner
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/__init__.py", line 69, in get_formatted_email
    return cstr(make_header(decode_header(formataddr((fullname, mail)))))
  File "/usr/lib/python2.7/email/header.py", line 139, in make_header
    h.append(s, charset)
  File "/usr/lib/python2.7/email/header.py", line 267, in append
    ustr = unicode(s, incodec, errors)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 10: ordinal not in range(128)
Traceback (most recent call last):
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/rq/worker.py", line 793, in perform_job
    rv = job.perform()
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/rq/job.py", line 599, in perform
    self._result = self._execute()
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/rq/job.py", line 605, in _execute
    return self.func(*self.args, **self.kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/background_jobs.py", line 102, in execute_job
    method(**kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 736, in pull_from_email_account
    email_account.receive()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 299, in receive
    communication.notify(attachments=attachments, fetched_from_email_account=True)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/communication.py", line 204, in notify
    fetched_from_email_account)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/email.py", line 127, in notify
    fetched_from_email_account=fetched_from_email_account)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/email.py", line 212, in get_recipients_cc_and_bcc
    cc = get_cc(doc, recipients, fetched_from_email_account=fetched_from_email_account)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/email.py", line 356, in get_cc
    cc.append(get_owner_email(doc))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/email.py", line 459, in get_owner_email
    return get_formatted_email(owner) or owner
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/__init__.py", line 69, in get_formatted_email
    return cstr(make_header(decode_header(formataddr((fullname, mail)))))
  File "/usr/lib/python2.7/email/header.py", line 139, in make_header
    h.append(s, charset)
  File "/usr/lib/python2.7/email/header.py", line 267, in append
    ustr = unicode(s, incodec, errors)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 10: ordinal not in range(128)
14:36:03 Moving job to u'failed' queue

maybe someone could help me with that?

Installed Apps

ERPNext: v12.9.4 (version-12)
Frappe Framework: v12.6.2 (version-12)

br
Andreas

Possibly the problem is you are running Python 2.7 that is no longer supported.

A forum search on bench migrate-env python3 will give you pointers to upgrade.

Hi,

after migrating to python3 it’s working.

Thanks!