无法从confluent_kafka导入生产者

2024-09-28 21:21:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我将conda环境与Python3.9和confluent_kafka库(由pip安装confluent kafka安装)一起使用。我还安装了librdkafka。我无法从pycharm导入:

from confluent_kafka import Producer

我收到以下错误:

Traceback (most recent call last):
  File "D:/Python/Projects/Kafka/main.py", line 1, in <module>
    from confluent_kafka import Producer
  File "C:\Users\kmode\anaconda3\envs\dataScience\lib\site-packages\confluent_kafka\__init__.py", line 40, in <module>
    from .deserializing_consumer import DeserializingConsumer
  File "C:\Users\kmode\anaconda3\envs\dataScience\lib\site-packages\confluent_kafka\deserializing_consumer.py", line 19, in <module>
    from confluent_kafka.cimpl import Consumer as _ConsumerImpl
ImportError: DLL load failed while importing cimpl: 

你能帮我解决这个问题吗


Tags: producerkafkainfrompyimportlineusers
2条回答

答案已经存在


我看到了一个与您类似的答案(根本不是重复的,但它解决了您的问题)。
How to resolve "ImportError: DLL load failed:" on Python?


他们建议卸载然后重新安装python,如果我理解得很好,它就可以工作了


其他人安装了Anaconda,它也起了作用

在重新插入anaconda并删除Python3.9之后,我修复了使用Python3.7发布的问题。在水蟒环境中。如前所述here原因是版本为3.8及更高版本,但我不知道如何在Python3.8及更高版本上准确地解决它

If anyone comes across this issue in Python > 3.8 with Windows, dll's are only loaded from trusted locations https://docs.python.org/3/whatsnew/3.8.html#ctypes This can be fixed by adding the dll path using os.add_dll_directory("PATH_TO_DLL")

相关问题 更多 >