简体   繁体   English

在Mac上导入tweepy错误

[英]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. 我在Windows 10上成功运行了tweepy,但是当我在Mac上运行相同的应用程序时,导入tweepy语句后,它在空闲状态崩溃并出现以下错误。 It seems to be something inside the tweepy module which I am not sure how to fix. 似乎在tweepy模块内部,我不确定该如何解决。

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 好的-所以在StackOverflow上没有真正的响应,所以我在网上看起来有点困难,并在这里找到了这个https://github.com/tweepy/tweepy/issues/1017

"stoictrader commented on May 9 • “ stoictrader在5月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? 相同的问题,但在Windows10 x64 python3.7 beta上,在python3.6上工作正常,因此似乎与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." 显然,异步不能在Python 3.7中用作参数名称。因此,请打开streaming.py并将#async替换为async_,它为我解决了该错误。”

I got into streaming.py on my mac and replaced async with async_ (all occurrences). 我进入Mac上的streaming.py,并用async_(所有情况)替换了async。 That took care of the problem. 那解决了这个问题。 So indeed async cannot be used as a variable on MacOS but it is fine on Windows. 因此,实际上异步不能在MacOS上用作变量,但在Windows上可以使用。 Seems like a simple fix for the developer of tweepy to change it from async to async_. 似乎是tweepy开发人员将其从async更改为async_的简单修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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