Try ERPNext Buy Support Partners Foundation

TypeError: the JSON object must be str, not 'bytes'

erpnext 12.x.x-develop
frappe 11.1.3
Python 3.5.2

Environment successfully migrated to python 3.
Database migrated.
On bench update TypeError: the JSON object must be str, not ‘bytes’ error is coming.
Error
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/nivedita/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 97, in
main()
File “/home/nivedita/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/nivedita/frappe-bench/env/lib/python3.5/site-packages/click/core.py”, line 764, in call
return self.main(*args, **kwargs)
File “/home/nivedita/frappe-bench/env/lib/python3.5/site-packages/click/core.py”, line 717, in main
rv = self.invoke(ctx)
File “/home/nivedita/frappe-bench/env/lib/python3.5/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/nivedita/frappe-bench/env/lib/python3.5/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/nivedita/frappe-bench/env/lib/python3.5/site-packages/click/core.py”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/nivedita/frappe-bench/env/lib/python3.5/site-packages/click/core.py”, line 555, in invoke
return callback(*args, **kwargs)
File “/home/nivedita/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/nivedita/frappe-bench/apps/frappe/frappe/commands/init.py”, line 25, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/nivedita/frappe-bench/apps/frappe/frappe/commands/site.py”, line 227, in migrate
migrate(context.verbose, rebuild_website=rebuild_website)
File “/home/nivedita/frappe-bench/apps/frappe/frappe/migrate.py”, line 53, in migrate
router.sync_global_search()
File “/home/nivedita/frappe-bench/apps/frappe/frappe/website/router.py”, line 355, in sync_global_search
sync_global_search()
File “/home/nivedita/frappe-bench/apps/frappe/frappe/utils/global_search.py”, line 314, in sync_global_search
value = json.loads(frappe.cache().lpop(‘global_search_queue’))
File “/usr/lib/python3.5/json/init.py”, line 312, in loads
s.class.name))
TypeError: the JSON object must be str, not ‘bytes’

When I am typing localhost:8000. it is opening. i can access everything but when when I am going to develop any customization , I am getting that error.

Kindly help.

You may have to choose which branch you prefer here…

Can you please give me an example on that , As it is not very clear to me.
Thanks for the help.

I’m getting this too.

ERPNext: v11.1.3 (master)
Frappe Framework: v11.1.3 (master)

Traceback (most recent call last):
  File "/home/frappe/bench/apps/frappe/frappe/utils/background_jobs.py", line 103, in execute_job
	method(**kwargs)
  File "/home/frappe/bench/apps/frappe/frappe/utils/global_search.py", line 314, in sync_global_search
	value = json.loads(frappe.cache().lpop('global_search_queue'))
  File "/usr/lib/python3.5/json/__init__.py", line 312, in loads
	s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'

After restart redis server, the error has gone.

1 Like

Normally ERPNext and Frappe should be on the same branch.

Your ERPNext is on develop branch and frappe is on master branch.

i having the same issue with frappe v12.0.20, I am not using erpnext app. I have only frappe. but i am getting the same error.

I have added .decode(‘utf-8’) at the end of line 120 and 122 to solve this issue in frappe/api.py
but its not a good solution.

The problem is with python version 3.5 (which is used by Ubuntu 16). Frappe and Erpnext now assumes python version 3.6 (which is used by Ubuntu 18). If you are using Ubuntu 16, either migrate to Ubuntu 18, or upgrade to python 3.6