python - 无法为 python 导入 tweepy
问题描述
使用 jupyter 笔记本
import tweepy
但是,我收到以下错误消息
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2961, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-2-f5e4f2180e08>", line 1, in <module>
import tweepy
File "C:\ProgramData\Anaconda3\lib\site-packages\tweepy-3.6.0-py3.7.egg\tweepy\__init__.py", line 17, in <module>
from tweepy.streaming import Stream, StreamListener
File "C:\ProgramData\Anaconda3\lib\site-packages\tweepy-3.6.0-py3.7.egg\tweepy\streaming.py", line 358
def _start(self, async):
^
SyntaxError: invalid syntax
我该怎么做才能解决这个问题?当我在命令提示符下运行 conda list 时,它会说。
# Name Version Build Channel
tweepy 3.6.0 <pip>
解决方案
async
在 Python 3.7 中不能用作参数名称。
请参阅:https ://docs.python.org/3/whatsnew/3.7.html#summary-release-highlights
async和await现在是保留关键字。
这个问题是已知的:https ://github.com/tweepy/tweepy/issues/1017
当前的建议是手动重命名 /tweepy/streaming.py 中所有出现的async
to async_
,直到有新版本可用。