confluent-kafka-python icon indicating copy to clipboard operation
confluent-kafka-python copied to clipboard

"module 'os' has no attribute 'add_dll_directory'"

Open pradeepjaladi opened this issue 1 year ago • 3 comments

Description

Getting the above error when importing the from confluent_kafka.admin import (AdminClient, NewTopic)

How to reproduce

  1. Spin up a Amazon Linux EC2 environment
  2. Check Python3 Version (3.7.6)
  3. create a directory /usr/local/source/sample
  4. sudo pip3 install -U confluent-kafka -t python WARNING: Running pip install with root privileges is generally not a good idea. Try pip3 install --user instead. Collecting confluent-kafka Using cached confluent_kafka-2.0.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.9 MB) Installing collected packages: confluent-kafka Successfully installed confluent-kafka-2.0.2
  5. zip the python file as confluent-kafka.zip
  6. download the zip file to windows environment
  7. Create a AWS Lambda Layer using the zip file
  8. Attach the Lambda layer to the Lambda function (Python 3.9)
  9. Test the Lambda function

Checklist

Please provide the following information:

  • [x] confluent-kafka-python and librdkafka version (2.02):
  • [x] Apache Kafka broker version: AWS MSK 2.8.1
  • [ ] Client configuration: {...}
  • [x] Operating system: Lambda Function
  • [ ] Provide client logs (with 'debug': '..' as necessary)
  • [ ] Provide broker log excerpts
  • [ ] Critical issue

pradeepjaladi avatar Mar 06 '23 12:03 pradeepjaladi

I already reviewed the https://github.com/confluentinc/confluent-kafka-python/issues/1462 & https://github.com/confluentinc/confluent-kafka-python/issues/1528

pradeepjaladi avatar Mar 06 '23 12:03 pradeepjaladi

Lambda function (Python 3.9)

Then why are you using Python 3.7 on EC2 to write the code? Also, don't use sudo to run pip, as the error says
Why do you need EC2 if you're going to submit the code to the lambda from Windows?

OneCricketeer avatar Apr 03 '23 01:04 OneCricketeer

@pradeepjaladi is this still an issue you are facing?

nhaq-confluent avatar Feb 13 '24 02:02 nhaq-confluent