Yelp/kafka-utils

running kafka-utils in python3 virtual env gives error.

Closed this issue · 4 comments

Hi Guys,
I have installed kafka-utils using pip. After activating the virtual environment I have created $HOME/.kafka_discovery/cluster.yaml . I tried to kafka-utils and I get the errors below:

py3venv) osboxes@osboxes:~/kafka/bin$ kafka-utils
Traceback (most recent call last):
File "/home/osboxes/py3venv/bin/kafka-utils", line 6, in
run()
File "/home/osboxes/py3venv/lib/python3.6/site-packages/kafka_utils/main.py", line 55, in run
for config in iter_configurations(args.discovery_base_path):
File "/home/osboxes/py3venv/lib/python3.6/site-packages/kafka_utils/util/config.py", line 274, in iter_configurations
config_dir,
File "/home/osboxes/py3venv/lib/python3.6/site-packages/kafka_utils/util/config.py", line 111, in init
self.load_topology_config()
File "/home/osboxes/py3venv/lib/python3.6/site-packages/kafka_utils/util/config.py", line 133, in load_topology_config
topology_config = load_yaml_config(config_path)
File "/home/osboxes/py3venv/lib/python3.6/site-packages/kafka_utils/util/config.py", line 69, in load_yaml_config
return yaml.safe_load(config_file)
File "/home/osboxes/py3venv/lib/python3.6/site-packages/yaml/init.py", line 162, in safe_load
return load(stream, SafeLoader)
File "/home/osboxes/py3venv/lib/python3.6/site-packages/yaml/init.py", line 114, in load
return loader.get_single_data()
File "/home/osboxes/py3venv/lib/python3.6/site-packages/yaml/constructor.py", line 41, in get_single_data
node = self.get_single_node()
File "/home/osboxes/py3venv/lib/python3.6/site-packages/yaml/composer.py", line 36, in get_single_node
document = self.compose_document()
File "/home/osboxes/py3venv/lib/python3.6/site-packages/yaml/composer.py", line 55, in compose_document
node = self.compose_node(None, None)
File "/home/osboxes/py3venv/lib/python3.6/site-packages/yaml/composer.py", line 84, in compose_node
node = self.compose_mapping_node(anchor)
File "/home/osboxes/py3venv/lib/python3.6/site-packages/yaml/composer.py", line 127, in compose_mapping_node
while not self.check_event(MappingEndEvent):
File "/home/osboxes/py3venv/lib/python3.6/site-packages/yaml/parser.py", line 98, in check_event
self.current_event = self.state()
File "/home/osboxes/py3venv/lib/python3.6/site-packages/yaml/parser.py", line 439, in parse_block_mapping_key
"expected , but found %r" % token.id, token.start_mark)
yaml.parser.ParserError: while parsing a block mapping
in "/home/osboxes/.kafka_discovery/cluster.yaml", line 1, column 1
expected , but found ''
in "/home/osboxes/.kafka_discovery/cluster.yaml", line 6, column 3

Any thoughts?

@huntusa based on the error message my guess is the cluster.yaml file might be wrongly formatted. Do you mind sharing it (feel free to redact any parts if necessary)

@huntusa based on the error message my guess is the cluster.yaml file might be wrongly formatted. Do you mind sharing it (feel free to redact any parts if necessary)

Thanks Baisang, You were correct after fixing my Yaml everything went back to normal and now its's working.

I forgot to mention that I ran it outside of virtual env without activating the virtual environment. However, when I run it in python virtual env I get kafka-utils not found when I can see that kafka-utils is installed just by running pip list.

when I run it in python virtual env I get "kafka-utils not found" when I can see that kafka-utils is installed just by running pip list.I will open a separate ticket for it. Closing this ticket.