导入kafka错误,kafka-python

import kafka error, kafka-python

环境:centos,python2.7.9 kafka-python==0.9.3 六==1.9.0

我是 kafka 的新手,我只是在尝试一个示例程序并遇到以下错误。任何帮助,将不胜感激。 该代码在 "from kafka import KafkaClient, KeyedProducer, RoundRobinPartitioner"

中引发错误
Traceback (most recent call last):
  File "send_kafka/send_monitor.py", line 4, in <module>
    from kafka import KafkaClient, KeyedProducer, RoundRobinPartitioner
  File "/usr/local/lib/python2.7/site-packages/kafka/__init__.py", line 4, in <module>
    __version__ = pkg_resources.require('kafka-python')[0].version
  File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 666, in require
  File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 565, in resolve
pkg_resources.DistributionNotFound: six

如果我尝试 "pip install distribute",

Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/site-packages/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 784, in install
    **kwargs
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 247, in move_wheel_files
    prefix=prefix,
  File "/usr/local/lib/python2.7/site-packages/pip/locations.py", line 140, in distutils_scheme
    d = Distribution(dist_args)
  File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/dist.py", line 261, in __init__
    for ep in pkg_resources.iter_entry_points('distutils.setup_keywords'):
  File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 476, in iter_entry_points
    entries = dist.get_entry_map(group)
  File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 2229, in get_entry_map
    self._get_metadata('entry_points.txt'), self
  File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 2034, in parse_map
    for group, lines in data:
  File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 2560, in split_sections
    for line in yield_lines(s):
  File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1854, in yield_lines
    for ss in strs:
  File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 2163, in _get_metadata
    for line in self.get_metadata_lines(name):
  File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1181, in get_metadata_lines
    return yield_lines(self.get_metadata(name))
  File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1178, in get_metadata
    return self._get(self._fn(self.egg_info,name))
  File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1238, in _get
    return self.loader.get_data(path)
IOError: zipimport: can not open file /usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
sudo python -m pip uninstall setuptools
wget https://pypi.python.org/packages/source/s/setuptools/setuptools-19.2.zip
unzip setuptools-19.2.zip
cd setuptools-19.2
python setup.py install
sudo python -m pip install distribute

完成!