Twittersearch模块未导入api fi

2024-09-27 19:30:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图使twitter搜索api一切正常,但突然twittersearch()模块没有得到导入。我使用的是Python3.4.2和Windows8.164位。我尝试过easy\u install twittersearch,它成功地安装了软件包,一切正常,但当我运行此代码时

from TwitterSearch import *
import pyodbc
cnxn = pyodbc.connect(driver='{SQL Server}', server='localhost', database='capstone',trusted_connection='yes')
cursor = cnxn.cursor()
cursor.execute("select word from dbo.search where sl in (select max(sl) from  dbo.search)")
for row in cursor.fetchall():
print (row)
print("This is positive data ")
term = row[0]
try:
tso=TwitterSearchOrder()
tso.set_keywords([term])
tso.set_language('en')

当我执行这个命令时,它会显示如下错误

Traceback (most recent call last):
File "C:\Python34\search_test.py", line 18, in <module>
tso=TwitterSearchOrder()
NameError: name 'TwitterSearchOrder' is not defined

但它实际上在那里,我不知道为什么它不能识别模块。直到2天前,它在IDLE下成功运行,但在commandprompt中没有,我重新安装了python并添加了所有工具,现在它在IDLE和commandprompt中都显示了这个错误 短暂性脑缺血发作


Tags: 模块infromimportsearchselectcursorrow
1条回答
网友
1楼 · 发布于 2024-09-27 19:30:55

确保TwitterSearch位于lib\site packages路径中。如果是的话,你一定是安装对了。如果不是,那么命令提示符下的一个简单的python -m pip install TwitterSearch就可以了。你知道吗

然而,TwitterSearch的函数似乎有一个问题(bug)。您可以同时考虑使用另一个API。我建议使用Tweepy

相关问题 更多 >

    热门问题