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.

@alan
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/runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 94, in <module>
    main()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/frappe/frappe-bench/env/lib/python3.5/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.5/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/env/lib/python3.5/site-packages/click/core.py", 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/core.py", 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/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe-bench/env/lib/python3.5/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 24, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/utils.py", line 41, in clear_cache
    frappe.clear_cache()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 510, in clear_cache
    frappe.sessions.clear_cache()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/sessions.py", line 50, in clear_cache
    clear_notifications(user)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/notifications.py", line 163, in clear_notifications
    config = get_notification_config()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/notifications.py", line 220, in get_notification_config
    return frappe.cache().get_value("notification_config", _get)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/redis_wrapper.py", line 72, in get_value
    val = generator()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/notifications.py", line 214, in _get
    nc = frappe.get_attr(notification_config)()
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/startup/notifications.py", line 77, in get_notification_config
    fields= ["name"], filters = {"name": ("not in", doctype), 'is_submittable': 1}):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1177, in get_all
    return get_list(doctype, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", 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/db_query.py", line 88, in execute
    result = self.build_and_run()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/db_query.py", line 100, in build_and_run
    args = self.prepare_args()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/db_query.py", line 119, in prepare_args
    self.build_conditions()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/db_query.py", line 279, in build_conditions
    self.build_filter_conditions(self.filters, self.conditions)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/db_query.py", line 300, in build_filter_conditions
    conditions.append(self.prepare_filter_condition(f))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/db_query.py", line 330, in prepare_filter_condition
    value = '("{0}")'.format('", "'.join(value))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/db_query.py", 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/database.py", 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/converters.py", 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 https://erpnext.org/get-started.

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]

If that does not help then report the problem https://github.com/frappe/erpnext/issues

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