Reputation: 173
I am using CentOS and have installed Python 3. Kakfa-Python has been installed using the command below.
sudo python3 -m pip install kafka-python
Then I started Python shell and tried to import kafkaProducer. But I got the error.
$ python3
Python 3.6.8 (default, Aug 7 2019, 17:28:10)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from kafka import kafkaProducer
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'kafkaProducer'
Then I tried the code below to ensure that the module has not be imported.
>>> producer = kafkaProducer(bootstrap_servers='host1')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'kafkaProducer' is not defined
Most of the time, the "cannot import name xxxxxx" error is caused by a module name conflict, and I can fix it by renaming my own python script file. However, right now I am in a REPL and I have not created any file/module yet.
Upvotes: 1
Views: 8306