Blinkt MQTT and Python 3.9


I have a new freshly installed Pi0 with the Blinkt connected to it, and it works great with the examples provided. However I’m trying to set it up with MQTT and everytime I send a message it crashes with the message
TypeError: a bytes-like object is required, not ‘str’

I’ve been doing some googling, and it looks like somehow python now requires changing of the topics to bytes, but I can’t really figure out if I should do it in the code and where, or when I’m sending the messages and in that case how.

Does anyone have a working example of the MQTT example for Python 3.9?

Traceback (most recent call last):
File “/home/nbla/Pimoroni/blinkt3/examples/./”, line 105, in
File “/home/nbla/.local/lib/python3.9/site-packages/paho/mqtt/”, line 1756, in loop_forever
rc = self._loop(timeout)
File “/home/nbla/.local/lib/python3.9/site-packages/paho/mqtt/”, line 1164, in _loop
rc = self.loop_read()
File “/home/nbla/.local/lib/python3.9/site-packages/paho/mqtt/”, line 1556, in loop_read
rc = self._packet_read()
File “/home/nbla/.local/lib/python3.9/site-packages/paho/mqtt/”, line 2439, in _packet_read
rc = self._packet_handle()
File “/home/nbla/.local/lib/python3.9/site-packages/paho/mqtt/”, line 3033, in _packet_handle
return self._handle_publish()
File “/home/nbla/.local/lib/python3.9/site-packages/paho/mqtt/”, line 3327, in _handle_publish
File “/home/nbla/.local/lib/python3.9/site-packages/paho/mqtt/”, line 3570, in _handle_on_message
on_message(self, self._userdata, message)
File “/home/nbla/Pimoroni/blinkt3/examples/./”, line 55, in on_message
data = msg.payload.split(‘,’)
TypeError: a bytes-like object is required, not ‘str’