You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by Kafka Shil <ka...@gmail.com> on 2020/08/28 18:25:46 UTC

confluent-kafka python library is not working with ubutu14 and python3

I am using "confluent-kafka==1.0.1". It works fine when I am using py3 and
ubuntu18, but fails with py3 and ubuntu14. I get the following error.

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/metrics_agent/kafka_writer.py",
line 147, in enqueue_for_topic
    producer.produce(topic_name, msg,
partition=_get_partition(producer, topic_name))
  File "/usr/local/lib/python3.4/dist-packages/confluent_kafka/serializing_producer.py",
line 168, in produce
    raise KeySerializationError(se)
confluent_kafka.error.KeySerializationError:
KafkaError{code=_KEY_SERIALIZATION,val=-162,str="'bytes' object has no
attribute 'encode'"}
Exception KafkaError{code=_KEY_SERIALIZATION,val=-162,str="'bytes'
object has no attribute 'encode'"}
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/confluent_kafka/serializing_producer.py",
line 166, in produce
    key = self._key_serializer(key, ctx)
  File "/usr/local/lib/python3.4/dist-packages/confluent_kafka/serialization/__init__.py",
line 369, in __call__
    return obj.encode(self.codec)
AttributeError: 'bytes' object has no attribute 'encode'