python-bittrex icon indicating copy to clipboard operation
python-bittrex copied to clipboard

TypeError: The JSON Object must be str, not bytes

Open Zalkota opened this issue 7 years ago • 2 comments

Any Idea how to fix this?

 File "trade.py", line 19, in <module>
    ethereumsummary = api.getmarketsummary(market)
  File "/home/user/Desktop/Projects/Bots/python-bittrex/bittrex/test/bittrex.py", line 62, in getmarketsummary
    return self.query('getmarketsummary', {'market': market})
  File "/home/user/Desktop/Projects/Bots/python-bittrex/bittrex/test/bittrex.py", line 41, in query
    response = json.loads(urllib.request.urlopen(req).read())
  File "/usr/lib/python3.4/json/__init__.py", line 312, in loads
    s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'

Zalkota avatar Nov 18 '17 05:11 Zalkota

Yes, change line 42 from: response = json.loads(urllib.request.urlopen(req).read()) to: response = json.loads(urllib.request.urlopen(req).read().decode('utf8'))

leexxg avatar Dec 06 '17 07:12 leexxg

that give us "TypeError: key: expected bytes or bytearray, but got 'str'"

espressocannon avatar Dec 20 '17 23:12 espressocannon