简体   繁体   中英

import tweepy error on Mac

I am running tweepy successfully on Windows 10 but when I run the same app on my Mac it crashes with the error below in Idle after the import tweepy statement. It seems to be something inside the tweepy module which I am not sure how to fix.

Traceback (most recent call last):
  File "/Users/arnoldrosielle/Desktop/PythonScripts/Twitter_Likes.py", line 9, in <module>
    import tweepy
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tweepy/__init__.py", line 17, in <module>
    from tweepy.streaming import Stream, StreamListener
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tweepy/streaming.py", line 358
    def _start(self, async):
                         ^
SyntaxError: invalid syntax

OK - so no real responses on StackOverflow so I looked a bit harder on the web and found this from here https://github.com/tweepy/tweepy/issues/1017

"stoictrader commented on May 9 •

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

I got into streaming.py on my mac and replaced async with async_ (all occurrences). That took care of the problem. So indeed async cannot be used as a variable on MacOS but it is fine on Windows. Seems like a simple fix for the developer of tweepy to change it from async to async_.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM