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

问题描述 投票:0回答:1

我安装了twint与:

pip3 install twint

导致安装成功:

Successfully installed twint-2.1.8

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

"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:\Users\myname\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
       execfile(filename, namespace)
      File "C:\Users\myname\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.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:\Users\myname\twint.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相关的问题,发现here,但此处提供的解决方案不适用于我。有谁知道错误来自哪里?我该如何解决?

python-3.x config python-module attributeerror
1个回答
0
投票
您链接到的问题与您遇到的问题完全相同。您需要将文件重命名为不是twint.py

如果遇到其他错误,那就是另外一个问题

© www.soinside.com 2019 - 2024. All rights reserved.