导入kafka错误,kafka python

p5cysglq  于 2021-06-07  发布在  Kafka
关注(0)|答案(1)|浏览(311)

env:centos,python2.7.9Kafkapython==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
xpcnnkqh

xpcnnkqh1#

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

完成!

相关问题