如何修复:属性错误:模块'twint'没有属性'config'



我已经安装了twint:

pip3 install twint

这导致了成功的安装:

Successfully installed twint-2.1.8

它可以使用命令提示符 (CLI( 命令从twitter获取推文,但是当我尝试在 IDE 中运行该示例Spyder它给了我错误:

"Traceback (most recent call last):
File "<ipython-input-13-7b77905cef0c>", line 1, in <module>
runfile('C:/Users/myname/twint.py', wdir='C:/Users/myname')
File "C:UsersmynameAnaconda3libsite-packagesspyder_kernelscustomizespydercustomize.py", line 827, in runfile
execfile(filename, namespace)
File "C:UsersmynameAnaconda3libsite-packagesspyder_kernelscustomizespydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/myname/twint.py", line 8, in <module>
import twint
File "C:Usersmynametwint.py", line 9, in <module>
c = twint.Config()
AttributeError: module 'twint' has no attribute 'Config'

这是我的代码:

import twint
c = twint.Config()
c.Username = "twitterAccountName"
twint.run.Search(c)

但是,我在 GitHub 上查找了与 twint 相关的问题 这里 找到,但这里提供的解决方案对我不起作用。有谁知道错误来自哪里?我该如何解决?

您链接到的问题与您遇到的问题完全相同。您需要重命名文件才能不 twint.py

将此文件重命名runfile('C:/Users/myname/twint.py

如果您遇到其他错误,那么这是一个单独的问题

最新更新