|
| 1 | +# confluent-kafka-python installation instructions |
| 2 | + |
| 3 | +## Install pre-built wheels (recommended) |
| 4 | + |
| 5 | +Confluent provides pre-built Python wheels of confluent-kafka-python with |
| 6 | +all dependencies included. |
| 7 | + |
| 8 | +To install, simply do: |
| 9 | + |
| 10 | +```bash |
| 11 | +python3 -m pip install confluent-kafka |
| 12 | +``` |
| 13 | + |
| 14 | +If you get a build error or require Kerberos/GSSAPI support please read the next section: *Install from source* |
| 15 | + |
| 16 | + |
| 17 | +## Install from source |
| 18 | + |
| 19 | +It is sometimes necessary to install confluent-kafka from source, rather |
| 20 | +than from prebuilt binary wheels, such as when: |
| 21 | + - You need GSSAPI/Kerberos authentication. |
| 22 | + - You're on a Python version we do not provide prebuilt wheels for. |
| 23 | + - You're on an architecture or platform we do not provide prebuilt wheels for. |
| 24 | + - You want to build confluent-kafka-python from the master branch. |
| 25 | + |
| 26 | + |
| 27 | +### Install from source on RedHat, CentOS, Fedora, etc |
| 28 | + |
| 29 | +```bash |
| 30 | +# |
| 31 | +# Perform these steps as the root user (e.g., in a 'sudo bash' shell) |
| 32 | +# |
| 33 | + |
| 34 | +# Install build tools and Kerberos support. |
| 35 | + |
| 36 | +yum install -y python3 python3-pip python3-devel gcc make cyrus-sasl-gssapi krb5-workstation |
| 37 | + |
| 38 | +# Install the latest version of librdkafka: |
| 39 | + |
| 40 | +rpm --import https://packages.confluent.io/rpm/7.0/archive.key |
| 41 | + |
| 42 | +echo ' |
| 43 | +[Confluent-Clients] |
| 44 | +name=Confluent Clients repository |
| 45 | +baseurl=https://packages.confluent.io/clients/rpm/centos/$releasever/$basearch |
| 46 | +gpgcheck=1 |
| 47 | +gpgkey=https://packages.confluent.io/clients/rpm/archive.key |
| 48 | +enabled=1' > /etc/yum.repos.d/confluent.repo |
| 49 | + |
| 50 | +yum install -y librdkafka-devel |
| 51 | + |
| 52 | + |
| 53 | +# |
| 54 | +# Now build and install confluent-kafka-python as your standard user |
| 55 | +# (e.g., exit the root shell first). |
| 56 | +# |
| 57 | + |
| 58 | +python3 -m pip install --no-binary confluent-kafka confluent-kafka |
| 59 | + |
| 60 | + |
| 61 | +# Verify that confluent_kafka is installed: |
| 62 | + |
| 63 | +python3 -c 'import confluent_kafka; print(confluent_kafka.version())' |
| 64 | +``` |
| 65 | + |
| 66 | +### Install from source on Debian or Ubuntu |
| 67 | + |
| 68 | +```bash |
| 69 | +# |
| 70 | +# Perform these steps as the root user (e.g., in a 'sudo bash' shell) |
| 71 | +# |
| 72 | + |
| 73 | +# Install build tools and Kerberos support. |
| 74 | + |
| 75 | +apt install -y wget software-properties-common lsb-release gcc make python3 python3-pip python3-dev libsasl2-modules-gssapi-mit krb5-user |
| 76 | + |
| 77 | + |
| 78 | +# Install the latest version of librdkafka: |
| 79 | + |
| 80 | +wget -qO - https://packages.confluent.io/deb/7.0/archive.key | apt-key add - |
| 81 | + |
| 82 | +add-apt-repository "deb https://packages.confluent.io/clients/deb $(lsb_release -cs) main" |
| 83 | + |
| 84 | +apt update |
| 85 | + |
| 86 | +apt install -y librdkafka-dev |
| 87 | + |
| 88 | + |
| 89 | +# |
| 90 | +# Now build and install confluent-kafka-python as your standard user |
| 91 | +# (e.g., exit the root shell first). |
| 92 | +# |
| 93 | + |
| 94 | +python3 -m pip install --no-binary confluent-kafka confluent-kafka |
| 95 | + |
| 96 | + |
| 97 | +# Verify that confluent_kafka is installed: |
| 98 | + |
| 99 | +python3 -c 'import confluent_kafka; print(confluent_kafka.version())' |
| 100 | +``` |
| 101 | + |
| 102 | + |
| 103 | +### Install from source on Mac OS X |
| 104 | + |
| 105 | +```bash |
| 106 | + |
| 107 | +# Install librdkafka from homebrew |
| 108 | + |
| 109 | +brew install librdkafka |
| 110 | + |
| 111 | + |
| 112 | +# Build and install confluent-kafka-python |
| 113 | + |
| 114 | +python3 -m pip install --no-binary confluent-kafka confluent-kafka |
| 115 | + |
| 116 | + |
| 117 | +# Verify that confluent_kafka is installed: |
| 118 | + |
| 119 | +python3 -c 'import confluent_kafka; print(confluent_kafka.version())' |
| 120 | + |
| 121 | +``` |
0 commit comments