开发者社区> 问答> 正文

kafka-python通过Snappy压缩访问时,报Snappy codec ?报错

1、测试环境:

    CentOS6.5_64位、JDK1.7、kafka版本为:kafka_2.9.2-0.8.2.2,zookeeper版本为:zookeeper-3.4.6,

kafka-python-0.9.4 。

2、测试步骤:

    已经安装好zookeeper和kafaka环境,设置codec=CODEC_SNAPPY则报错,codec=CODEC_NONE或者是codec=CODEC_GZIP则正常,此时怀疑是未安装SNAPPY

    安装SNAPPY,进行测试,发现还是报错:

错误如下:

Traceback (most recent call last):
  File "/usr/local/kafkaTest/producer.py", line 67, in <module>
    main()
  File "/usr/local/kafkaTest/producer.py", line 63, in main
    load(hostname, max_size, loaded)
  File "/usr/local/kafkaTest/producer.py", line 22, in load
    producer.send_messages('topic1', big_msg)
  File "build/bdist.linux-x86_64/egg/kafka/producer/simple.py", line 54, in send_messages
  File "build/bdist.linux-x86_64/egg/kafka/producer/base.py", line 349, in send_messages
  File "build/bdist.linux-x86_64/egg/kafka/producer/base.py", line 385, in _send_messages
  File "build/bdist.linux-x86_64/egg/kafka/protocol.py", line 603, in create_message_set
  File "build/bdist.linux-x86_64/egg/kafka/protocol.py", line 586, in create_snappy_message
  File "build/bdist.linux-x86_64/egg/kafka/codec.py", line 76, in snappy_encode
NotImplementedError: Snappy codec is not available

测试代码如下:

producer = SimpleProducer(client,async=False,codec=CODEC_SNAPPY,req_acks=0,ack_timeout=2000,sync_fail_on_error=False)
<p>
	<br>
</p>
<p>
	<br>
</p>



展开
收起
爱吃鱼的程序员 2020-06-10 11:03:09 868 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    解决了,参考kafka-python中的install.rst可以解决

    2020-06-10 11:03:26
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Java Spring Boot开发实战系列课程【第16讲】:Spring Boot 2.0 实战Apache Kafka百万级高并发消息中间件与原理解析 立即下载
MaxCompute技术公开课第四季 之 如何将Kafka数据同步至MaxCompute 立即下载
消息队列kafka介绍 立即下载