async invalid syntax
See original GitHub issueI’m fairly new to coding—just taking a coding class this semester. I’m using a MacBook Air and downloaded PyCharm, and so far, I’ve been able to figure most things out, but I’m stuck on this one.
I’m trying to get the tweepy Stream Listener to return the tweets for a certain hashtag, and this code worked without issue on the Windows computers on campus. The code I’m running looks like this:
import tweepy
#override tweepy.StreamListener to add logic to on_status
class MyStreamListener(tweepy.StreamListener):
def on_status(self, status):
print(status.text)
def on_error(self, status_code):
if status_code == 420:
# returning False in on_data disconnects the stream
return False
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
myStreamListener = MyStreamListener()
myStream = tweepy.Stream(auth, listener=myStreamListener)
myStream.filter(track=['#fakenews'])
On my computer, it returns this error:
Traceback (most recent call last): File “/Users/USERNAME/PycharmProjects/Homework/Twitter.py”, line 7, in <module> import tweepy File “/Users/USERNAME/PycharmProjects/Homework/venv/lib/python3.7/site-packages/tweepy/init.py”, line 17, in <module> from tweepy.streaming import Stream, StreamListener File “/Users/USERNAME/PycharmProjects/Homework/venv/lib/python3.7/site-packages/tweepy/streaming.py”, line 358 def _start(self, async): ^ SyntaxError: invalid syntax
The carat is actually under async
, not at the beginning of the line. The last two “files” are the code from the tweepy module, not any code I’ve written or searched through.
I’ve tried changing the interpreter for my project in PyCharm, but I’m not sure what else to try. My professor looked at it and didn’t want to get into the backend code (and honestly, I don’t either, since I don’t really know what I’m doing), so I’m stuck as to what to try next or actually what the real issue is.
Any suggestions?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:15 (4 by maintainers)
Top GitHub Comments
The same issue but on Windows10 x64 python3.7 beta, on python3.6 it works fine, so seems like incompatibility with python 3.7? Okay found the solution. Apparently async cannot be used as an argument name in Python 3.7 So open streaming.py and replace #async with async_ it fixed the error for me.
this will stay an issue amongst users trying to pip install this package on python > 3.7(as there is no anaconda) when will you upload the fix?