pythondjangoapache-kafkadjango-celeryfaust

ModuleNotFoundError("'kafka' is not a valid name. Did you mean one of aiokafka, kafka?")


I am using Celery and Kafka to run some jobs in order to push data to Kafka. I also use Faust to connect the workers. But unfortunately, I got an error after running faust -A project.streams.app worker -l info in order to run the pipeline. I wonder if anyone can help me.

/home/admin/.local/lib/python3.6/site-packages/faust/fixups/django.py:71: UserWarning: Using settings.DEBUG leads to a memory leak, never
use this setting in production environments!

  warnings.warn(WARN_DEBUG_ENABLED)
Command raised exception: ModuleNotFoundError("'kafka' is not a valid name. Did you mean one of aiokafka, kafka?",)
  File "/home/admin/.local/lib/python3.6/site-packages/mode/worker.py", line 67, in exiting
    yield
  File "/home/admin/.local/lib/python3.6/site-packages/faust/cli/base.py", line 528, in _inner
    cmd()
  File "/home/admin/.local/lib/python3.6/site-packages/faust/cli/base.py", line 611, in __call__
    self.run_using_worker(*args, **kwargs)
  File "/home/admin/.local/lib/python3.6/site-packages/faust/cli/base.py", line 620, in run_using_worker
    self.on_worker_created(worker)
  File "/home/admin/.local/lib/python3.6/site-packages/faust/cli/worker.py", line 57, in on_worker_created
    self.say(self.banner(worker))
  File "/home/admin/.local/lib/python3.6/site-packages/faust/cli/worker.py", line 97, in banner
    self._banner_data(worker))
  File "/home/admin/.local/lib/python3.6/site-packages/faust/cli/worker.py", line 127, in _banner_data
    ('  transport', app.transport.driver_version),
  File "/home/admin/.local/lib/python3.6/site-packages/faust/app/base.py", line 1831, in transport
    self._transport = self._new_transport()
  File "/home/admin/.local/lib/python3.6/site-packages/faust/app/base.py", line 1686, in _new_transport
    return transport.by_url(self.conf.broker_consumer[0])(
  File "/home/admin/.local/lib/python3.6/site-packages/mode/utils/imports.py", line 101, in by_url
    return self.by_name(URL(url).scheme)
  File "/home/admin/.local/lib/python3.6/site-packages/mode/utils/imports.py", line 115, in by_name
    f'{name!r} is not a valid name. {alt}') from exc

Solution

  • I don't know what was wrong with Faust but I run pip install faust by chance and it solved the problem.