centos 離線安裝confluent_kafka 模組
阿新 • • 發佈:2018-11-05
centos 離線安裝confluent_kafka 模組
背景:需要安裝Python模組的機子不能上網,只能下載原始碼進行安裝
說明:如果可以上網直接pip install confluent_kafka
即可
需安裝模組:
confluent_kafka #confluent_kafka 依賴librdkafka 模組:
librdkafka
安裝包下載:
https://pypi.org/project/confluent-kafka/
https://github.com/edenhill/librdkafka
安裝:
先安裝librdkafka 模組:
cd librdkafka
./configure --prefix=/usr
make
make install
ldconfig
再安裝confluent_kafka 模組:
cd confluent_kafka
python setup.py install
測試:
import confluent_kafka
如果出現錯誤:
from .cimpl import (Consumer, # noqa
ImportError: librdkafka.so.1: cannot open shared object file: No such file or directory
解決辦法:
ldconfig
如果出現錯誤:
confluent_kafka/src/confluent_kafka.h:21 :32: fatal error: librdkafka/rdkafka.h: No such file or directory
#include <librdkafka/rdkafka.h>
^
compilation terminated.
error: command 'gcc' failed with exit status 1
解決辦法:
./configure --prefix=/usr #增加字首
make
make -j
make install
ldconfig
#如果仍報錯,在本機搜尋librdkafka/rdkafka.h是否存在,如果已經存在,那麼退出或者新建一個終端重新嘗試即可
如果出現錯誤:
In file included from confluent_kafka/src/confluent_kafka.c:17:0:
confluent_kafka/src/confluent_kafka.h:17:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
error: command 'gcc' failed with exit status 1
解決辦法:
yum install python-dev
參考連結:
https://blog.csdn.net/qq_35887983/article/details/79308723
https://github.com/confluentinc/confluent-kafka-python/issues/184
https://github.com/confluentinc/confluent-kafka-python/issues/65