首页 > 解决方案 > pip install 命令出错,退出状态为 1

问题描述

我有这个requirments.txt文件:

confluent-kafka[avro]==1.1.0

当我运行命令时 -

$ pip3 install -r requirments.txt

这是我收到的错误:

ERROR: Command errored out with exit status 1:
     command: /usr/local/opt/python@3.9/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/k4/q3psbyqj0l79b8ch527mr36h0000gp/T/pip-install-d8igj48w/confluent-kafka_abe9a32f37bd4b23be43de3e07b30fb2/setup.py'"'"'; __file__='"'"'/private/var/folders/k4/q3psbyqj0l79b8ch527mr36h0000gp/T/pip-install-d8igj48w/confluent-kafka_abe9a32f37bd4b23be43de3e07b30fb2/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/k4/q3psbyqj0l79b8ch527mr36h0000gp/T/pip-record-60zlo4l3/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.9/confluent-kafka
         cwd: /private/var/folders/k4/q3psbyqj0l79b8ch527mr36h0000gp/T/pip-install-d8igj48w/confluent-kafka_abe9a32f37bd4b23be43de3e07b30fb2/
    Complete output (34 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.15-x86_64-3.9
    creating build/lib.macosx-10.15-x86_64-3.9/confluent_kafka
    copying confluent_kafka/__init__.py -> build/lib.macosx-10.15-x86_64-3.9/confluent_kafka
    creating build/lib.macosx-10.15-x86_64-3.9/confluent_kafka/admin
    copying confluent_kafka/admin/__init__.py -> build/lib.macosx-10.15-x86_64-3.9/confluent_kafka/admin
    creating build/lib.macosx-10.15-x86_64-3.9/confluent_kafka/avro
    copying confluent_kafka/avro/error.py -> build/lib.macosx-10.15-x86_64-3.9/confluent_kafka/avro
    copying confluent_kafka/avro/__init__.py -> build/lib.macosx-10.15-x86_64-3.9/confluent_kafka/avro
    copying confluent_kafka/avro/cached_schema_registry_client.py -> build/lib.macosx-10.15-x86_64-3.9/confluent_kafka/avro
    copying confluent_kafka/avro/load.py -> build/lib.macosx-10.15-x86_64-3.9/confluent_kafka/avro
    creating build/lib.macosx-10.15-x86_64-3.9/confluent_kafka/kafkatest
    copying confluent_kafka/kafkatest/verifiable_client.py -> build/lib.macosx-10.15-x86_64-3.9/confluent_kafka/kafkatest
    copying confluent_kafka/kafkatest/__init__.py -> build/lib.macosx-10.15-x86_64-3.9/confluent_kafka/kafkatest
    copying confluent_kafka/kafkatest/verifiable_consumer.py -> build/lib.macosx-10.15-x86_64-3.9/confluent_kafka/kafkatest
    copying confluent_kafka/kafkatest/verifiable_producer.py -> build/lib.macosx-10.15-x86_64-3.9/confluent_kafka/kafkatest
    creating build/lib.macosx-10.15-x86_64-3.9/confluent_kafka/avro/serializer
    copying confluent_kafka/avro/serializer/__init__.py -> build/lib.macosx-10.15-x86_64-3.9/confluent_kafka/avro/serializer
    copying confluent_kafka/avro/serializer/message_serializer.py -> build/lib.macosx-10.15-x86_64-3.9/confluent_kafka/avro/serializer
    running build_ext
    building 'confluent_kafka.cimpl' extension
    creating build/temp.macosx-10.15-x86_64-3.9
    creating build/temp.macosx-10.15-x86_64-3.9/confluent_kafka
    creating build/temp.macosx-10.15-x86_64-3.9/confluent_kafka/src
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/sqlite/include -I/usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c confluent_kafka/src/Admin.c -o build/temp.macosx-10.15-x86_64-3.9/confluent_kafka/src/Admin.o
    In file included from confluent_kafka/src/Admin.c:17:
    confluent_kafka/src/confluent_kafka.h:22:10: fatal error: 'librdkafka/rdkafka.h' file not found
    #include <librdkafka/rdkafka.h>
             ^~~~~~~~~~~~~~~~~~~~~~
    1 error generated.
    error: command '/usr/bin/clang' failed with exit code 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/opt/python@3.9/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/k4/q3psbyqj0l79b8ch527mr36h0000gp/T/pip-install-d8igj48w/confluent-kafka_abe9a32f37bd4b23be43de3e07b30fb2/setup.py'"'"'; __file__='"'"'/private/var/folders/k4/q3psbyqj0l79b8ch527mr36h0000gp/T/pip-install-d8igj48w/confluent-kafka_abe9a32f37bd4b23be43de3e07b30fb2/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/k4/q3psbyqj0l79b8ch527mr36h0000gp/T/pip-record-60zlo4l3/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.9/confluent-kafka Check the logs for full command output.

使用的python版本是 -

$ python3 --version

Python 3.9.5

这里有什么问题以及如何解决?

标签: pythonpip

解决方案


您需要.h开发标头。 sudo apt install librdkafka-dev


推荐阅读