pythonapache-kafkaconfluent-kafka-python

Error installing confluent kafka - ld: library not found for -lrdkafka


I am trying to install confluent kafka python module on my mac os. My python version is 3.9 I am keep getting below error.

Does anyone know how to fix this?

      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c /private/var/folders/tm/l00fw55n55vgglqsy56lhgbh0000gn/T/pip-install-eocpb3xa/confluent-kafka_f77dbcfd032f447791927683e1f5f56b/src/confluent_kafka/src/confluent_kafka.c -o build/temp.macosx-12-arm64-cpython-39/private/var/folders/tm/l00fw55n55vgglqsy56lhgbh0000gn/T/pip-install-eocpb3xa/confluent-kafka_f77dbcfd032f447791927683e1f5f56b/src/confluent_kafka/src/confluent_kafka.o
      /private/var/folders/tm/l00fw55n55vgglqsy56lhgbh0000gn/T/pip-install-eocpb3xa/confluent-kafka_f77dbcfd032f447791927683e1f5f56b/src/confluent_kafka/src/confluent_kafka.c:2545:9: warning: 'PyEval_InitThreads' is deprecated [-Wdeprecated-declarations]
              PyEval_InitThreads();
              ^
      /opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9/ceval.h:130:1: note: 'PyEval_InitThreads' has been explicitly marked deprecated here
      Py_DEPRECATED(3.9) PyAPI_FUNC(void) PyEval_InitThreads(void);
      ^
      /opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9/pyport.h:508:54: note: expanded from macro 'Py_DEPRECATED'
      #define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
                                                           ^
      1 warning generated.
      clang -bundle -undefined dynamic_lookup build/temp.macosx-12-arm64-cpython-39/private/var/folders/tm/l00fw55n55vgglqsy56lhgbh0000gn/T/pip-install-eocpb3xa/confluent-kafka_f77dbcfd032f447791927683e1f5f56b/src/confluent_kafka/src/Admin.o build/temp.macosx-12-arm64-cpython-39/private/var/folders/tm/l00fw55n55vgglqsy56lhgbh0000gn/T/pip-install-eocpb3xa/confluent-kafka_f77dbcfd032f447791927683e1f5f56b/src/confluent_kafka/src/AdminTypes.o build/temp.macosx-12-arm64-cpython-39/private/var/folders/tm/l00fw55n55vgglqsy56lhgbh0000gn/T/pip-install-eocpb3xa/confluent-kafka_f77dbcfd032f447791927683e1f5f56b/src/confluent_kafka/src/Consumer.o build/temp.macosx-12-arm64-cpython-39/private/var/folders/tm/l00fw55n55vgglqsy56lhgbh0000gn/T/pip-install-eocpb3xa/confluent-kafka_f77dbcfd032f447791927683e1f5f56b/src/confluent_kafka/src/Metadata.o build/temp.macosx-12-arm64-cpython-39/private/var/folders/tm/l00fw55n55vgglqsy56lhgbh0000gn/T/pip-install-eocpb3xa/confluent-kafka_f77dbcfd032f447791927683e1f5f56b/src/confluent_kafka/src/Producer.o build/temp.macosx-12-arm64-cpython-39/private/var/folders/tm/l00fw55n55vgglqsy56lhgbh0000gn/T/pip-install-eocpb3xa/confluent-kafka_f77dbcfd032f447791927683e1f5f56b/src/confluent_kafka/src/confluent_kafka.o -lrdkafka -o build/lib.macosx-12-arm64-cpython-39/confluent_kafka/cimpl.cpython-39-darwin.so
      ld: library not found for -lrdkafka
      clang: error: linker command failed with exit code 1 (use -v to see invocation)
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> confluent-kafka

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
WARNING: There was an error checking the latest version of pip.

Solution

  • You appear to be using an M1 Mac.

    This is an open issue for aarch64 / arm64 libraries https://github.com/confluentinc/confluent-kafka-python/issues/1190

    In the meantime, you might be able to use kafka-python or aiokafka since they don't depend on librdkafka.