2

I'm using conda environment with python 3.9 and confluent_kafka library (installation by pip install confluent-kafka). I have also installed librdkafka. From pycharm I cannot import:

from confluent_kafka import Producer

I receive this errors:

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: 

Can you help to solve this problem?

Sven Eberth
  • 3,057
  • 12
  • 24
  • 29
Krzysiek
  • 31
  • 1
  • 6

3 Answers3

1

After reinstalations of anaconda and removing python 3.9 I fixed the issued by using python 3.7. in anaconda environment. As stated here the reason is to have version 3.8 and higher, but I don't know how to resolve it exactly on python 3.8 and above.

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")

Nol4635
  • 631
  • 1
  • 14
  • 24
Krzysiek
  • 31
  • 1
  • 6
0

Answer already existing


I saw an answer similar to yours (not a duplicate at all, but it solves your problem).
How to resolve "ImportError: DLL load failed:" on Python?


They suggested to uninstall and then reinstall python, and if I understood well it worked.


Somebody else installed Anaconda instead, and it worked too.

FLAK-ZOSO
  • 3,873
  • 4
  • 8
  • 28
0

For those who are using Anaconda with Python>=3.8, set your environment variable.

set CONDA_DLL_SEARCH_MODIFICATION_ENABLE=1
Kit Law
  • 323
  • 6
  • 15