kfka学习笔记一:使用Python操作Kafka
1、准备工作
使用python操作kafka目前比较常用的库是kafka-python库,但是在安装这个库的时候需要依赖setuptools库和six库,下面就要分别来下载这几个库
https://pypi.org/project/kafka-python/#files
1.1 下载setuptools
1.2 下载kafka-python
1.3 下载six
下载略
注意版本:
我开始用的setuptools-0.6c11-py2.6.egg + kafka-python-1.4.4.tar.gz + six-1.12.0.tar.gz包,安装后,from kafka import KafkaProducer 是出错,可能原因事版本问题。重新换了一下面的版本,就好了。
2、安装相关python库
在上一步里面我们已经下载了好相关的包,下面开始具体安装,首先创建一个/opt/python_library/,然后把这几个包文件上传到这里
[root@centos03 python_library]# ll
total 600
drwxr-xr-x. 7 5579 5579 4096 Dec 1 21:20 kafka-python-1.3.5
-rw-r--r--. 1 root root 227497 Dec 1 21:18 kafka-python-1.3.5.tar.gz
-rw-r--r--. 1 root root 333447 Dec 1 20:26 setuptools-0.6c11-py2.6.egg
drwxr-xr-x. 6 2000 2000 4096 Dec 1 21:19 six-1.11.0
-rw-r--r--. 1 root root 29860 Dec 1 21:18 six-1.11.0.tar.gz
[root@centos03 python_library]#
2.1 安装setuptools
[root@centos03 python_library]# sh setuptools-.6c11-py2..egg
Processing setuptools-.6c11-py2..egg
Copying setuptools-.6c11-py2..egg to /usr/lib/python2./site-packages
Adding setuptools .6c11 to easy-install.pth file
Installing easy_install script to /usr/bin
Installing easy_install-2.6 script to /usr/bin Installed /usr/lib/python2./site-packages/setuptools-.6c11-py2..egg
Processing dependencies for setuptools==.6c11
Finished processing dependencies for setuptools==.6c11
[root@centos03 python_library]#
2.2 安装six
[root@centos03 six-1.11.0]# ll
total 140
drwxr-xr-x. 4 root root 4096 Dec 1 21:19 build
-rw-r--r--. 1 2000 2000 7970 Sep 18 2017 CHANGES
drwxr-xr-x. 2 root root 4096 Dec 1 21:19 dist
drwxr-xr-x. 2 2000 2000 4096 Sep 18 2017 documentation
-rw-r--r--. 1 2000 2000 1066 Sep 18 2017 LICENSE
-rw-r--r--. 1 2000 2000 114 Sep 18 2017 MANIFEST.in
-rw-r--r--. 1 2000 2000 1818 Sep 18 2017 PKG-INFO
-rw-r--r--. 1 2000 2000 1096 Sep 18 2017 README.rst
-rw-r--r--. 1 2000 2000 282 Sep 18 2017 setup.cfg
-rw-r--r--. 1 2000 2000 2184 Sep 18 2017 setup.py
drwxr-xr-x. 2 2000 2000 4096 Sep 18 2017 six.egg-info
-rw-r--r--. 1 2000 2000 30888 Sep 18 2017 six.py
-rw-r--r--. 1 root root 30782 Dec 1 21:19 six.pyc
-rw-r--r--. 1 2000 2000 26864 Sep 18 2017 test_six.py
[root@centos03 six-1.11.0]#
执行python setup.py install
[root@centos03 six-1.11.0]# python setup.py install
running install
running bdist_egg
running egg_info
writing six.egg-info/PKG-INFO
writing top-level names to six.egg-info/top_level.txt
writing dependency_links to six.egg-info/dependency_links.txt
writing six.egg-info/PKG-INFO
writing top-level names to six.egg-info/top_level.txt
writing dependency_links to six.egg-info/dependency_links.txt
reading manifest file 'six.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'documentation/_build'
writing manifest file 'six.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build/bdist.linux-x86_64/egg
copying build/lib/six.py -> build/bdist.linux-x86_64/egg
byte-compiling build/bdist.linux-x86_64/egg/six.py to six.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying six.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying six.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying six.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying six.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
six: module references __path__
creating 'dist/six-1.11.0-py2.6.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing six-1.11.0-py2.6.egg
removing '/usr/lib/python2.6/site-packages/six-1.11.0-py2.6.egg' (and everything under it)
creating /usr/lib/python2.6/site-packages/six-1.11.0-py2.6.egg
Extracting six-1.11.0-py2.6.egg to /usr/lib/python2.6/site-packages
six 1.11.0 is already the active version in easy-install.pth
Installed /usr/lib/python2.6/site-packages/six-1.11.0-py2.6.egg
Processing dependencies for six==1.11.0
Finished processing dependencies for six==1.11.0
[root@centos03 six-1.11.0]#
2.3 安装kafka-python
执行tar -zxvf kafka-python-1.3.4.tar.gz解压安装包,会产生kafka-python-1.3.4文件夹,进入到该文件夹
[root@centos03 python_library]# tar -zxvf kafka-python-1.3.5.tar.gz
[root@centos03 kafka-python-1.3.5]# ll
total 100
-rw-r--r--. 1 5579 5579 2508 Jan 24 2016 AUTHORS.md
drwxr-xr-x. 4 root root 4096 Dec 1 21:20 build
-rw-r--r--. 1 5579 5579 33359 Oct 8 2017 CHANGES.md
drwxr-xr-x. 2 root root 4096 Dec 1 21:20 dist
drwxr-xr-x. 10 5579 5579 4096 Dec 1 21:20 kafka
drwxr-xr-x. 2 5579 5579 4096 Oct 8 2017 kafka_python.egg-info
-rw-r--r--. 1 5579 5579 11343 Jan 24 2016 LICENSE
-rw-r--r--. 1 5579 5579 102 Jan 24 2016 MANIFEST.in
-rw-r--r--. 1 5579 5579 8164 Oct 8 2017 PKG-INFO
-rw-r--r--. 1 5579 5579 6056 Oct 8 2017 README.rst
-rw-r--r--. 1 5579 5579 67 Oct 8 2017 setup.cfg
-rw-r--r--. 1 5579 5579 1754 Oct 8 2017 setup.py
drwxr-xr-x. 2 5579 5579 4096 Oct 8 2017 test
[root@centos03 kafka-python-1.3.5]#
执行python setup.py install
[root@centos03 kafka-python-1.3.5]# python setup.py install
running install
running bdist_egg
running egg_info
writing kafka_python.egg-info/PKG-INFO
writing top-level names to kafka_python.egg-info/top_level.txt
writing dependency_links to kafka_python.egg-info/dependency_links.txt
writing kafka_python.egg-info/PKG-INFO
writing top-level names to kafka_python.egg-info/top_level.txt
writing dependency_links to kafka_python.egg-info/dependency_links.txt
reading manifest file 'kafka_python.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'kafka_python.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/kafka
copying build/lib/kafka/errors.py -> build/bdist.linux-x86_64/egg/kafka
copying build/lib/kafka/structs.py -> build/bdist.linux-x86_64/egg/kafka
copying build/lib/kafka/codec.py -> build/bdist.linux-x86_64/egg/kafka
creating build/bdist.linux-x86_64/egg/kafka/vendor
copying build/lib/kafka/vendor/socketpair.py -> build/bdist.linux-x86_64/egg/kafka/vendor
copying build/lib/kafka/vendor/six.py -> build/bdist.linux-x86_64/egg/kafka/vendor
copying build/lib/kafka/vendor/selectors34.py -> build/bdist.linux-x86_64/egg/kafka/vendor
copying build/lib/kafka/vendor/__init__.py -> build/bdist.linux-x86_64/egg/kafka/vendor
copying build/lib/kafka/future.py -> build/bdist.linux-x86_64/egg/kafka
copying build/lib/kafka/common.py -> build/bdist.linux-x86_64/egg/kafka
creating build/bdist.linux-x86_64/egg/kafka/producer
copying build/lib/kafka/producer/future.py -> build/bdist.linux-x86_64/egg/kafka/producer
copying build/lib/kafka/producer/keyed.py -> build/bdist.linux-x86_64/egg/kafka/producer
copying build/lib/kafka/producer/buffer.py -> build/bdist.linux-x86_64/egg/kafka/producer
copying build/lib/kafka/producer/__init__.py -> build/bdist.linux-x86_64/egg/kafka/producer
copying build/lib/kafka/producer/kafka.py -> build/bdist.linux-x86_64/egg/kafka/producer
copying build/lib/kafka/producer/sender.py -> build/bdist.linux-x86_64/egg/kafka/producer
copying build/lib/kafka/producer/record_accumulator.py -> build/bdist.linux-x86_64/egg/kafka/producer
copying build/lib/kafka/producer/simple.py -> build/bdist.linux-x86_64/egg/kafka/producer
copying build/lib/kafka/producer/base.py -> build/bdist.linux-x86_64/egg/kafka/producer
copying build/lib/kafka/version.py -> build/bdist.linux-x86_64/egg/kafka
creating build/bdist.linux-x86_64/egg/kafka/consumer
copying build/lib/kafka/consumer/group.py -> build/bdist.linux-x86_64/egg/kafka/consumer
copying build/lib/kafka/consumer/fetcher.py -> build/bdist.linux-x86_64/egg/kafka/consumer
copying build/lib/kafka/consumer/multiprocess.py -> build/bdist.linux-x86_64/egg/kafka/consumer
copying build/lib/kafka/consumer/subscription_state.py -> build/bdist.linux-x86_64/egg/kafka/consumer
copying build/lib/kafka/consumer/__init__.py -> build/bdist.linux-x86_64/egg/kafka/consumer
copying build/lib/kafka/consumer/simple.py -> build/bdist.linux-x86_64/egg/kafka/consumer
copying build/lib/kafka/consumer/base.py -> build/bdist.linux-x86_64/egg/kafka/consumer
copying build/lib/kafka/client_async.py -> build/bdist.linux-x86_64/egg/kafka
copying build/lib/kafka/context.py -> build/bdist.linux-x86_64/egg/kafka
copying build/lib/kafka/cluster.py -> build/bdist.linux-x86_64/egg/kafka
creating build/bdist.linux-x86_64/egg/kafka/partitioner
copying build/lib/kafka/partitioner/default.py -> build/bdist.linux-x86_64/egg/kafka/partitioner
copying build/lib/kafka/partitioner/hashed.py -> build/bdist.linux-x86_64/egg/kafka/partitioner
copying build/lib/kafka/partitioner/__init__.py -> build/bdist.linux-x86_64/egg/kafka/partitioner
copying build/lib/kafka/partitioner/roundrobin.py -> build/bdist.linux-x86_64/egg/kafka/partitioner
copying build/lib/kafka/partitioner/base.py -> build/bdist.linux-x86_64/egg/kafka/partitioner
creating build/bdist.linux-x86_64/egg/kafka/coordinator
copying build/lib/kafka/coordinator/consumer.py -> build/bdist.linux-x86_64/egg/kafka/coordinator
copying build/lib/kafka/coordinator/heartbeat.py -> build/bdist.linux-x86_64/egg/kafka/coordinator
copying build/lib/kafka/coordinator/protocol.py -> build/bdist.linux-x86_64/egg/kafka/coordinator
copying build/lib/kafka/coordinator/__init__.py -> build/bdist.linux-x86_64/egg/kafka/coordinator
copying build/lib/kafka/coordinator/base.py -> build/bdist.linux-x86_64/egg/kafka/coordinator
creating build/bdist.linux-x86_64/egg/kafka/coordinator/assignors
copying build/lib/kafka/coordinator/assignors/range.py -> build/bdist.linux-x86_64/egg/kafka/coordinator/assignors
copying build/lib/kafka/coordinator/assignors/__init__.py -> build/bdist.linux-x86_64/egg/kafka/coordinator/assignors
copying build/lib/kafka/coordinator/assignors/abstract.py -> build/bdist.linux-x86_64/egg/kafka/coordinator/assignors
copying build/lib/kafka/coordinator/assignors/roundrobin.py -> build/bdist.linux-x86_64/egg/kafka/coordinator/assignors
creating build/bdist.linux-x86_64/egg/kafka/metrics
copying build/lib/kafka/metrics/kafka_metric.py -> build/bdist.linux-x86_64/egg/kafka/metrics
copying build/lib/kafka/metrics/metric_name.py -> build/bdist.linux-x86_64/egg/kafka/metrics
copying build/lib/kafka/metrics/metrics.py -> build/bdist.linux-x86_64/egg/kafka/metrics
copying build/lib/kafka/metrics/metric_config.py -> build/bdist.linux-x86_64/egg/kafka/metrics
copying build/lib/kafka/metrics/compound_stat.py -> build/bdist.linux-x86_64/egg/kafka/metrics
creating build/bdist.linux-x86_64/egg/kafka/metrics/stats
copying build/lib/kafka/metrics/stats/total.py -> build/bdist.linux-x86_64/egg/kafka/metrics/stats
copying build/lib/kafka/metrics/stats/max_stat.py -> build/bdist.linux-x86_64/egg/kafka/metrics/stats
copying build/lib/kafka/metrics/stats/sampled_stat.py -> build/bdist.linux-x86_64/egg/kafka/metrics/stats
copying build/lib/kafka/metrics/stats/sensor.py -> build/bdist.linux-x86_64/egg/kafka/metrics/stats
copying build/lib/kafka/metrics/stats/percentiles.py -> build/bdist.linux-x86_64/egg/kafka/metrics/stats
copying build/lib/kafka/metrics/stats/histogram.py -> build/bdist.linux-x86_64/egg/kafka/metrics/stats
copying build/lib/kafka/metrics/stats/percentile.py -> build/bdist.linux-x86_64/egg/kafka/metrics/stats
copying build/lib/kafka/metrics/stats/__init__.py -> build/bdist.linux-x86_64/egg/kafka/metrics/stats
copying build/lib/kafka/metrics/stats/min_stat.py -> build/bdist.linux-x86_64/egg/kafka/metrics/stats
copying build/lib/kafka/metrics/stats/avg.py -> build/bdist.linux-x86_64/egg/kafka/metrics/stats
copying build/lib/kafka/metrics/stats/count.py -> build/bdist.linux-x86_64/egg/kafka/metrics/stats
copying build/lib/kafka/metrics/stats/rate.py -> build/bdist.linux-x86_64/egg/kafka/metrics/stats
copying build/lib/kafka/metrics/stat.py -> build/bdist.linux-x86_64/egg/kafka/metrics
copying build/lib/kafka/metrics/__init__.py -> build/bdist.linux-x86_64/egg/kafka/metrics
copying build/lib/kafka/metrics/measurable.py -> build/bdist.linux-x86_64/egg/kafka/metrics
copying build/lib/kafka/metrics/metrics_reporter.py -> build/bdist.linux-x86_64/egg/kafka/metrics
copying build/lib/kafka/metrics/measurable_stat.py -> build/bdist.linux-x86_64/egg/kafka/metrics
copying build/lib/kafka/metrics/quota.py -> build/bdist.linux-x86_64/egg/kafka/metrics
copying build/lib/kafka/metrics/dict_reporter.py -> build/bdist.linux-x86_64/egg/kafka/metrics
creating build/bdist.linux-x86_64/egg/kafka/protocol
copying build/lib/kafka/protocol/group.py -> build/bdist.linux-x86_64/egg/kafka/protocol
copying build/lib/kafka/protocol/api.py -> build/bdist.linux-x86_64/egg/kafka/protocol
copying build/lib/kafka/protocol/message.py -> build/bdist.linux-x86_64/egg/kafka/protocol
copying build/lib/kafka/protocol/types.py -> build/bdist.linux-x86_64/egg/kafka/protocol
copying build/lib/kafka/protocol/produce.py -> build/bdist.linux-x86_64/egg/kafka/protocol
copying build/lib/kafka/protocol/fetch.py -> build/bdist.linux-x86_64/egg/kafka/protocol
copying build/lib/kafka/protocol/metadata.py -> build/bdist.linux-x86_64/egg/kafka/protocol
copying build/lib/kafka/protocol/frame.py -> build/bdist.linux-x86_64/egg/kafka/protocol
copying build/lib/kafka/protocol/__init__.py -> build/bdist.linux-x86_64/egg/kafka/protocol
copying build/lib/kafka/protocol/abstract.py -> build/bdist.linux-x86_64/egg/kafka/protocol
copying build/lib/kafka/protocol/pickle.py -> build/bdist.linux-x86_64/egg/kafka/protocol
copying build/lib/kafka/protocol/struct.py -> build/bdist.linux-x86_64/egg/kafka/protocol
copying build/lib/kafka/protocol/commit.py -> build/bdist.linux-x86_64/egg/kafka/protocol
copying build/lib/kafka/protocol/admin.py -> build/bdist.linux-x86_64/egg/kafka/protocol
copying build/lib/kafka/protocol/legacy.py -> build/bdist.linux-x86_64/egg/kafka/protocol
copying build/lib/kafka/protocol/offset.py -> build/bdist.linux-x86_64/egg/kafka/protocol
copying build/lib/kafka/__init__.py -> build/bdist.linux-x86_64/egg/kafka
copying build/lib/kafka/client.py -> build/bdist.linux-x86_64/egg/kafka
creating build/bdist.linux-x86_64/egg/kafka/serializer
copying build/lib/kafka/serializer/__init__.py -> build/bdist.linux-x86_64/egg/kafka/serializer
copying build/lib/kafka/serializer/abstract.py -> build/bdist.linux-x86_64/egg/kafka/serializer
copying build/lib/kafka/util.py -> build/bdist.linux-x86_64/egg/kafka
copying build/lib/kafka/conn.py -> build/bdist.linux-x86_64/egg/kafka
byte-compiling build/bdist.linux-x86_64/egg/kafka/errors.py to errors.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/structs.py to structs.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/codec.py to codec.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/vendor/socketpair.py to socketpair.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/vendor/six.py to six.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/vendor/selectors34.py to selectors34.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/vendor/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/future.py to future.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/common.py to common.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/producer/future.py to future.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/producer/keyed.py to keyed.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/producer/buffer.py to buffer.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/producer/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/producer/kafka.py to kafka.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/producer/sender.py to sender.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/producer/record_accumulator.py to record_accumulator.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/producer/simple.py to simple.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/producer/base.py to base.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/version.py to version.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/consumer/group.py to group.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/consumer/fetcher.py to fetcher.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/consumer/multiprocess.py to multiprocess.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/consumer/subscription_state.py to subscription_state.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/consumer/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/consumer/simple.py to simple.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/consumer/base.py to base.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/client_async.py to client_async.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/context.py to context.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/cluster.py to cluster.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/partitioner/default.py to default.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/partitioner/hashed.py to hashed.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/partitioner/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/partitioner/roundrobin.py to roundrobin.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/partitioner/base.py to base.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/coordinator/consumer.py to consumer.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/coordinator/heartbeat.py to heartbeat.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/coordinator/protocol.py to protocol.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/coordinator/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/coordinator/base.py to base.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/coordinator/assignors/range.py to range.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/coordinator/assignors/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/coordinator/assignors/abstract.py to abstract.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/coordinator/assignors/roundrobin.py to roundrobin.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/metrics/kafka_metric.py to kafka_metric.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/metrics/metric_name.py to metric_name.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/metrics/metrics.py to metrics.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/metrics/metric_config.py to metric_config.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/metrics/compound_stat.py to compound_stat.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/metrics/stats/total.py to total.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/metrics/stats/max_stat.py to max_stat.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/metrics/stats/sampled_stat.py to sampled_stat.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/metrics/stats/sensor.py to sensor.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/metrics/stats/percentiles.py to percentiles.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/metrics/stats/histogram.py to histogram.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/metrics/stats/percentile.py to percentile.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/metrics/stats/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/metrics/stats/min_stat.py to min_stat.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/metrics/stats/avg.py to avg.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/metrics/stats/count.py to count.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/metrics/stats/rate.py to rate.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/metrics/stat.py to stat.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/metrics/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/metrics/measurable.py to measurable.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/metrics/metrics_reporter.py to metrics_reporter.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/metrics/measurable_stat.py to measurable_stat.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/metrics/quota.py to quota.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/metrics/dict_reporter.py to dict_reporter.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/protocol/group.py to group.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/protocol/api.py to api.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/protocol/message.py to message.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/protocol/types.py to types.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/protocol/produce.py to produce.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/protocol/fetch.py to fetch.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/protocol/metadata.py to metadata.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/protocol/frame.py to frame.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/protocol/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/protocol/abstract.py to abstract.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/protocol/pickle.py to pickle.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/protocol/struct.py to struct.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/protocol/commit.py to commit.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/protocol/admin.py to admin.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/protocol/legacy.py to legacy.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/protocol/offset.py to offset.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/client.py to client.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/serializer/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/serializer/abstract.py to abstract.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/util.py to util.pyc
byte-compiling build/bdist.linux-x86_64/egg/kafka/conn.py to conn.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying kafka_python.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying kafka_python.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying kafka_python.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying kafka_python.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
kafka.vendor.six: module references __path__
creating 'dist/kafka_python-1.3.5-py2.6.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing kafka_python-1.3.5-py2.6.egg
removing '/usr/lib/python2.6/site-packages/kafka_python-1.3.5-py2.6.egg' (and everything under it)
creating /usr/lib/python2.6/site-packages/kafka_python-1.3.5-py2.6.egg
Extracting kafka_python-1.3.5-py2.6.egg to /usr/lib/python2.6/site-packages
kafka-python 1.3.5 is already the active version in easy-install.pth
Installed /usr/lib/python2.6/site-packages/kafka_python-1.3.5-py2.6.egg
Processing dependencies for kafka-python==1.3.5
Finished processing dependencies for kafka-python==1.3.5
[root@centos03 kafka-python-1.3.5]#
3、安装库测试
接下来测试一下,进入python ,导入KafkaProducer,如果没有提示找不到包就证明已经安装OK了
[root@centos03 kafka-python-1.3.]# python
Python 2.6. (r266:, Nov , ::)
[GCC 4.4. (Red Hat 4.4.-)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from kafka import KafkaProducer
>>> import kafka
>>> print(kafka.__version__)
1.3.
>>>
kfka学习笔记一:使用Python操作Kafka的更多相关文章
- python3.4学习笔记(十五) 字符串操作(string替换、删除、截取、复制、连接、比较、查找、包含、大小写转换、分割等)
python3.4学习笔记(十五) 字符串操作(string替换.删除.截取.复制.连接.比较.查找.包含.大小写转换.分割等) python print 不换行(在后面加上,end=''),prin ...
- Python3+Selenium3+webdriver学习笔记13(js操作应用:弹出框无效如何处理)
#!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记13(js操作应用:弹出框无效如何处理)'''from sel ...
- Python3+Selenium3+webdriver学习笔记12(js操作应用:滚动条 日历 内嵌div)
#!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记12(js操作应用:滚动条 日历 内嵌div)'''from ...
- kafka实战教程(python操作kafka),kafka配置文件详解
kafka实战教程(python操作kafka),kafka配置文件详解 应用往Kafka写数据的原因有很多:用户行为分析.日志存储.异步通信等.多样化的使用场景带来了多样化的需求:消息是否能丢失?是 ...
- RX学习笔记:JavaScript数组操作
RX学习笔记:JavaScript数组操作 2016-07-03 增删元素 unshift() 在数组开关添加元素 array.unshift("value"); array.un ...
- 树莓派学习笔记——使用文件IO操作GPIO SysFs方式
0 前言 本文描写叙述假设通过文件IO sysfs方式控制树莓派 GPIO端口.通过sysfs方式控制GPIO,先訪问/sys/class/gpio文件夹,向export文件写入GPIO编号, ...
- Windows phone 8 学习笔记(2) 数据文件操作
原文:Windows phone 8 学习笔记(2) 数据文件操作 Windows phone 8 应用用于数据文件存储访问的位置仅仅限于安装文件夹.本地文件夹(独立存储空间).媒体库和SD卡四个地方 ...
- 学习笔记《简明python教程》
学习笔记<简明python教程> 体会:言简意赅,很适合新手入门 2018年3月14日21:45:59 1.global 语句 在不使用 global 语句的情况下,不可能为一个定义于函数 ...
- ES6学习笔记<五> Module的操作——import、export、as
import export 这两个家伙对应的就是es6自己的 module功能. 我们之前写的Javascript一直都没有模块化的体系,无法将一个庞大的js工程拆分成一个个功能相对独立但相互依赖的小 ...
随机推荐
- iOS应用主流UI架构实现
一.介绍 如今iOS开发过程中,最常见的一种UI架构是:界面底部是四五个tab bar .中间是内容显示.顶部是包括标题及返回等操作button,当点击进入某个模块后可以点击进行返回.这样的架构的应用 ...
- 【c++版数据结构】之循环单链表的实现(带头结点以及尾节点)
所实现的循环单链表的结构例如以下图所看到的: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill ...
- CentOS 7通过yum安装fcitx五笔输入法
CentOS 7通过yum安装fcitx五笔输入法 下面通过了亲測: 1.设置源 Posted in Linux at 三月 5th, 2015 / No Comments ? 增加EPEL源 EPE ...
- 【cl】eclipse基本设置(字体、配置JDK)
字体 找到上面的菜单“windows”打开Preferences 在弹出的设置窗口中找到“colors and fonts” 将 ...
- iOS 8 UI布局 AutoLayout及SizeClass(二)
一.新特性Size Class介绍 随着iOS8系统的公布,一个全新的页面UI布局概念出现,这个新特性将颠覆包含iOS7及之前版本号的UI布局方式,这个新特性就是Size Class. Size Cl ...
- Android笔记之网络状态推断
1.首先当然得在 manifest 中加入检查网络状态的权限: <uses-permission android:name="android.permission.ACCESS_NET ...
- POJ1837 Balance 背包
题目大意: 有一个天平,天平左右两边各有若干个钩子,总共有C个钩子(每个钩子有相对于中心的距离,左负右正),有G个钩码,求将钩码全部挂到钩子上使天平平衡的方法的总数. 将每个砝码看作一组,组内各个物品 ...
- pom.xml出现web.xml is missing and <failOnMissingWebXml> is set to true解决方案
提示信息应该能看懂.也就是缺少了web.xml文件,<failOnMissingWebXml>被设置成true了. 搜索了一下,Stack Overflow上的答案解决了问题,分享一下. ...
- h5-10 canvas 简易祖玛
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- php创建简单的列表页
php创建简单的列表页 样例 代码 <?php $userInfo[] = array( 'id'=>'1', 'username'=>'fry', 'sex'=>'nan', ...