Got SyntaxError around self.async while import KafkaProducer on python 3.7.4
See original GitHub issueI’m using Python 3.7.4 in PyCharm 2019.1.4 (PY-191.8026.44). I have installed kafka-1.3.5. When I import KafkaProducer, I get an error:
(venv-py) D:\PycharmProjects\FCOP>python
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from kafka import KafkaProducer
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\PycharmProjects\FCOP\venv-py\lib\site-packages\kafka\__init__.py", line 23, in <module>
from kafka.producer import KafkaProducer
File "D:\PycharmProjects\FCOP\venv-py\lib\site-packages\kafka\producer\__init__.py", line 4, in <module>
from .simple import SimpleProducer
File "D:\PycharmProjects\FCOP\venv-py\lib\site-packages\kafka\producer\simple.py", line 54
return '<SimpleProducer batch=%s>' % self.async
^
SyntaxError: invalid syntax
>>>
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:6
Top Results From Across the Web
Got SyntaxError around self.async while ... - Stack Overflow
In my case it solved by installing "kafka-python" package . python -m pip install kafka ...
Read more >Got SyntaxError around self.async while import ... - Pinterest
Got SyntaxError around self.async while import KafkaProducer on python 3.7.4 · Issue ... Full Stack Data Science projects centered around Apache.
Read more >Syntaxerror On "Self.Async" When Running Python Kafka ...
I'm using Python 3.7.4 in PyCharm 2019.1.4 PY191.8026.44.I have installed kafka1.3.5.When I import KafkaProducer I get an error:. I'm using Python ...
Read more >Syntax error when running my program (Python 3)
[Example code]-Syntax error when running my program (Python 3). Related Posts. How to import a module in Python in a file that ...
Read more >pyatspi is not Python 3.7 compatible due to using "async" as a ...
pyatspi uses "async" as a attribute/argument name: ... line 114 self.async = False # not fully supported yet ^ SyntaxError: invalid syntax.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ohh, sorry, I get the issue. You seem to have
kafka
package installed, that is a forbidden package and is not updated. Please:kafka
andkafka-python
packages usingpip uninstall
commandkafka-python
package.You need to remove both packages to ensure python loads the
kafka
module properly. Sorry for the trouble. Relates to https://github.com/dpkp/kafka-python/issues/1253I am presently running on:
PS C:\Apache\Kafka\kafka_2.13-2.4.0\bin\windows> pip install kafka-python Requirement already satisfied: kafka-python in c:\python3.8.1\lib\site-packages (2.0.1)
yet I face this issue :
PS C:\Apache\Kafka\kafka_2.13-2.4.0\bin\windows> python .\test.py Traceback (most recent call last): File “.\test.py”, line 5, in from kafka import KafkaConsumer File “C:\python3.8.1\lib\site-packages\kafka_init_.py”, line 23, in from kafka.producer import KafkaProducer File “C:\python3.8.1\lib\site-packages\kafka\producer_init_.py”, line 4, in from .simple import SimpleProducer File “C:\python3.8.1\lib\site-packages\kafka\producer\simple.py”, line 54 return ‘’ % self.async ^
Any thoughts on how to fix this?