Error : TypeError: a bytes-like object is required, not 'list' after Bench Update

Hi all,
Was recently setup the development environment with this guide. After run bench update today, after run bench start, and when access to the site, it show the following error :

TypeError: a bytes-like object is required, not ‘list’

After some checking, I guess is because of python 2.7 is default version of my machine, but when I check the /frappe-bench/env/lib, the python version is 3.5, not sure this is the cause, kindly help to advise further how to solve this, thanks.

1 Like

anyone have any idea on this ? appreciate the help.

Send whole trackback so we can understand exact error.

frappe@ubuntu:~/frappe-bench$ bench clear-cache
Traceback (most recent call last):
  File "/usr/lib/python3.5/", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/", line 85, in _run_code
    exec(code, run_globals)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/", line 94, in <module>
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/", line 18, in main
  File "/home/frappe/frappe-bench/env/lib/python3.5/site-packages/click/", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.5/site-packages/click/", line 697, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/env/lib/python3.5/site-packages/click/", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.5/site-packages/click/", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.5/site-packages/click/", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe-bench/env/lib/python3.5/site-packages/click/", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.5/site-packages/click/", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/", line 24, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/", line 41, in clear_cache
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 510, in clear_cache
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 50, in clear_cache
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/", line 163, in clear_notifications
    config = get_notification_config()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/", line 220, in get_notification_config
    return frappe.cache().get_value("notification_config", _get)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/", line 72, in get_value
    val = generator()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/", line 214, in _get
    nc = frappe.get_attr(notification_config)()
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/startup/", line 77, in get_notification_config
    fields= ["name"], filters = {"name": ("not in", doctype), 'is_submittable': 1}):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 1177, in get_all
    return get_list(doctype, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 1150, in get_list
    return frappe.model.db_query.DatabaseQuery(doctype).execute(None, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 88, in execute
    result = self.build_and_run()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 100, in build_and_run
    args = self.prepare_args()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 119, in prepare_args
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 279, in build_conditions
    self.build_filter_conditions(self.filters, self.conditions)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 300, in build_filter_conditions
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 330, in prepare_filter_condition
    value = '("{0}")'.format('", "'.join(value))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 329, in <genexpr>
    value = (frappe.db.escape((v or '').strip(), percent=False) for v in values)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 904, in escape
    s = text_type(pymysql.escape_string(s), "utf-8").replace("`", "\\`")
  File "/home/frappe/frappe-bench/env/lib/python3.5/site-packages/pymysql/", line 73, in _escape_unicode
    return value.translate(_escape_table)
TypeError: a bytes-like object is required, not 'list'
1 Like

I just downloaded the erpnext virtual machine of 2018-03-31 from

I updated to latest version:

ERPNext 10.1.40
Frappé 10.1.37

I have the same error.

Does anyone know how to fix it?

Thanks in advanced

Same Error

1 Like

same error here too :frowning:

Same error!

Perhaps the change to python 3.5 from 2.7 has left your system in a confused state?

So try ‘bench update’ a couple more times.

If that does not help try this:

frappe-bench > cd apps/frappe
frappe-bench/apps/frappe > find . -name "*.pyc" -exec rm -f {} \;

Basically, all the .pyc needs to be rebuild because of changes in lots of core files.

As per here Switch branches in V11 [ cannot import name Database issue] - #15 by Zlash65

If that does not help then report the problem Issues · frappe/erpnext · GitHub

1 Like

changing the env now fix the problem …only migrate the rnv and it will be fixed

Python makes a clear distinction between bytes and strings . Bytes objects contain raw data — a sequence of octets — whereas strings are Unicode sequences . Conversion between these two types is explicit: you encode a string to get bytes, specifying an encoding (which defaults to UTF-8); and you decode bytes to get a string. Clients of these functions should be aware that such conversions may fail, and should consider how failures are handled.

We can convert bytes to string using bytes class decode() instance method, So you need to decode the bytes object to produce a string. In Python 3 , the default encoding is “utf-8” , so you can use directly:

b"python byte to string".decode("utf-8")

1 Like