无法在Mac Sierra上安装python包confluent-kafka

时间:2017-03-11 19:03:14

标签: python macos pip macos-sierra confluent-kafka

花了太多时间尝试安装confluent-kafka而没有运气。我知道有一个librdkafka依赖项,但似乎已成功安装。

尝试以下建议:

http://docs.confluent.io/3.1.1/installation.html#cpp-client

https://github.com/confluentinc/confluent-kafka-python/issues/6

https://github.com/confluentinc/confluent-kafka-go/issues/39

结果

MyMac1234567:~ joe.user$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.12.3
BuildVersion:   16D32

MyMac1234567:~ joe.user$ brew install openssl
Updating Homebrew...
==> Auto-updated Homebrew!
Updated Homebrew from bb3e509 to 7e5b2fb.
Updated 1 tap (homebrew/core).
==> Updated Formulae
kafka

Warning: openssl is a keg-only and another version is linked to opt.
Use `brew install --force` if you want to install this version

MyMac1234567:~ joe.user$ brew install librdkafka
==> Using the sandbox
==> Downloading https://github.com/edenhill/librdkafka/archive/0.9.1.tar.gz
Already downloaded: /Users/jeff.graham/Library/Caches/Homebrew/librdkafka-0.9.1.tar.gz
==> ./configure --prefix=/usr/local/Cellar/librdkafka/0.9.1
==> make
==> make install
  /usr/local/Cellar/librdkafka/0.9.1: 14 files, 1.3MB, built in 11 seconds

MyMac1234567:~ joe.user$ python -V
Python 2.7.10

MyMac1234567:~ joe.user$ pip -V
pip 9.0.1 from /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7)

MyMac1234567:~ joe.user$ sudo -H pip install confluent-kafka
Collecting confluent-kafka
  Using cached confluent-kafka-0.9.4.tar.gz
Installing collected packages: confluent-kafka
  Running setup.py install for confluent-kafka ... error
    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-VbLtMr/confluent-kafka/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-iPYPmz-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.12-intel-2.7
    creating build/lib.macosx-10.12-intel-2.7/confluent_kafka
    copying confluent_kafka/__init__.py -> build/lib.macosx-10.12-intel-2.7/confluent_kafka
    creating build/lib.macosx-10.12-intel-2.7/confluent_kafka/avro
    copying confluent_kafka/avro/__init__.py -> build/lib.macosx-10.12-intel-2.7/confluent_kafka/avro
    copying confluent_kafka/avro/cached_schema_registry_client.py -> build/lib.macosx-10.12-intel-2.7/confluent_kafka/avro
    creating build/lib.macosx-10.12-intel-2.7/confluent_kafka/kafkatest
    copying confluent_kafka/kafkatest/__init__.py -> build/lib.macosx-10.12-intel-2.7/confluent_kafka/kafkatest
    copying confluent_kafka/kafkatest/verifiable_client.py -> build/lib.macosx-10.12-intel-2.7/confluent_kafka/kafkatest
    copying confluent_kafka/kafkatest/verifiable_consumer.py -> build/lib.macosx-10.12-intel-2.7/confluent_kafka/kafkatest
    copying confluent_kafka/kafkatest/verifiable_producer.py -> build/lib.macosx-10.12-intel-2.7/confluent_kafka/kafkatest
    creating build/lib.macosx-10.12-intel-2.7/confluent_kafka/avro/serializer
    copying confluent_kafka/avro/serializer/__init__.py -> build/lib.macosx-10.12-intel-2.7/confluent_kafka/avro/serializer
    copying confluent_kafka/avro/serializer/message_serializer.py -> build/lib.macosx-10.12-intel-2.7/confluent_kafka/avro/serializer
    running build_ext
    building 'confluent_kafka.cimpl' extension
    creating build/temp.macosx-10.12-intel-2.7
    creating build/temp.macosx-10.12-intel-2.7/confluent_kafka
    creating build/temp.macosx-10.12-intel-2.7/confluent_kafka/src
    cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c confluent_kafka/src/confluent_kafka.c -o build/temp.macosx-10.12-intel-2.7/confluent_kafka/src/confluent_kafka.o
    cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c confluent_kafka/src/Producer.c -o build/temp.macosx-10.12-intel-2.7/confluent_kafka/src/Producer.o
    cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c confluent_kafka/src/Consumer.c -o build/temp.macosx-10.12-intel-2.7/confluent_kafka/src/Consumer.o
    cc -bundle -undefined dynamic_lookup -arch x86_64 -arch i386 -Wl,-F. build/temp.macosx-10.12-intel-2.7/confluent_kafka/src/confluent_kafka.o build/temp.macosx-10.12-intel-2.7/confluent_kafka/src/Producer.o build/temp.macosx-10.12-intel-2.7/confluent_kafka/src/Consumer.o -lrdkafka -o build/lib.macosx-10.12-intel-2.7/confluent_kafka/cimpl.so
    ld: warning: ignoring file /usr/local/lib/librdkafka.dylib, file was built for x86_64 which is not the architecture being linked (i386): /usr/local/lib/librdkafka.dylib
    running install_lib
    copying build/lib.macosx-10.12-intel-2.7/confluent_kafka/cimpl.so -> /Library/Python/2.7/site-packages/confluent_kafka
    running install_data
    copying LICENSE -> /System/Library/Frameworks/Python.framework/Versions/2.7/
    error: [Errno 1] Operation not permitted: '/System/Library/Frameworks/Python.framework/Versions/2.7/LICENSE'

    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-VbLtMr/confluent-kafka/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-iPYPmz-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-VbLtMr/confluent-kafka/

2 个答案:

答案 0 :(得分:1)

抱歉,我做错了很多事情:

酿造医生

**brew doctor found symlink issues:**
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
  freetds


brew link --overwrite --dry-run freetds

重新安装librdkafka

brew uninstall librdkafka
brew install librdkafka

最重要的是,发现我在这里跟随旧的/过时/危险的sudo做法。

https://github.com/ipython/ipython/issues/9523

使用 - 用户代替,我们很好。

pip install confluent-kafka --user
Collecting confluent-kafka
  Using cached confluent-kafka-0.9.4.tar.gz
Installing collected packages: confluent-kafka
  Running setup.py install for confluent-kafka ... done
Successfully installed confluent-kafka-0.9.4

很抱歉提前发布了一个问题。希望这会帮助别人。

答案 1 :(得分:1)

自El Capitan 10.11以来,Apple创建了一个系统完整性保护(SIP),甚至不允许超级用户更改这些文件夹中的任何内容:/ System,/ bin,/ sbin或/ usr(/ usr /除外)本地)。

MacOS El Capitan或更新版本的预先要求:

brew install pkg-config
brew upgrade openssl

echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
export LDFLAGS=-L/usr/local/opt/openssl/lib
export CPPFLAGS=-I/usr/local/opt/openssl/include

因此,我需要克隆并自己编译librdkafka,并将前缀fom / usr更改为/ usr / local

git clone https://github.com/edenhill/librdkafka.git
cd librdkafka
./configure --clean
./configure --prefix /usr/local 
make
sudo make install