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

1,005 views
Skip to first unread message

Alan Pierson

unread,
Aug 28, 2018, 8:28:02 AM8/28/18
to Got Your Back: Gmail Backup
Hi! I'm trying to run GYB on my Synology NAS device, which has Python 3 installed. It seems like GYB should work on the Synology, but I get a TypeError whenever I try to run it. 

In response to the command "python3 gyb.py --email [myemail]@gmail.com --action estimate", I get: 

Traceback (most recent call last):
  File "gyb.py", line 1875, in <module>
    main(sys.argv[1:])
  File "gyb.py", line 1198, in main
    doGYBCheckForUpdates(debug=options.debug)
  File "gyb.py", line 372, in doGYBCheckForUpdates
    release_data = json.loads(c)
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/json/__init__.py", line 312, in loads
    s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'

Can anyone help diagnose? 

Thanks, Alan 

Jay Lee

unread,
Aug 28, 2018, 8:29:05 AM8/28/18
to Got Your Back: Gmail Backup
What does:

gyb --version

Show?

--
--
You received this message because you are subscribed to the Google
Groups "Got Your Back: Gmail Backup" group.
To post to this group, send email to got-yo...@googlegroups.com
To unsubscribe from this group, send email to
got-your-bac...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/got-your-back?hl=en?hl=en

---
You received this message because you are subscribed to the Google Groups "Got Your Back: Gmail Backup" group.
To unsubscribe from this group and stop receiving emails from it, send an email to got-your-bac...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jay Lee

unread,
Aug 28, 2018, 8:31:37 AM8/28/18
to Got Your Back: Gmail Backup
Actually the issue here is GYB required Python 3.6 and you are using 3.5.

Jay

Alan Crosswell

unread,
Aug 28, 2018, 9:34:43 AM8/28/18
to got-yo...@googlegroups.com
The fix is to add .decode("utf-8") and then it will be portable across multiple python versions.

Alan Pierson

unread,
Aug 28, 2018, 9:54:41 AM8/28/18
to got-yo...@googlegroups.com
that's terrific! thank you!!!

subibro

unread,
Oct 13, 2018, 7:57:47 AM10/13/18
to Got Your Back: Gmail Backup
Not familiar with Python. How/where would one add .decode("utf-8") ?

subibro

unread,
Oct 13, 2018, 11:04:00 AM10/13/18
to Got Your Back: Gmail Backup
Found out myself. Line 372 in gyb.py, change to:
release_data = json.loads(c.decode('utf-8'))

The run the python3 command as instructed in the installation page:
python3 gyb.py --email your...@gmail.com --action estimate

That seemed to solve the issue, no errors.

Alan Crosswell

unread,
Oct 13, 2018, 11:39:56 AM10/13/18
to got-yo...@googlegroups.com
> Actually the issue here is GYB required Python 3.6 and you are using 3.5.

Yes, this is fixed in 3.6 but doesn't hurt to add backward compatibility. It's not always easy for people to know how to upgrade their python version, especially if they are not a python developer, and, in this case, running some sort of appliance OS that is back-level. For example, RHEL 6 only delivers 2.7 and 3.5.

You might want to consider using tox and/or travis to test for these kinds of backwards/forwarded compatibility (python 3.7 is out now!).  Here's an example:
Reply all
Reply to author
Forward
0 new messages