'How to fix 'Tweet' object has no attribute 'retweetCount'

Using snscrape for this example. With python 3.8 and snscrape 0.3.4

import snscrape.modules.twitter as sntwitter

keyword = '(COVID19)'

tdf = None

for i, tweet in enumerate(sntwitter.TwitterSearchScraper(keyword + ' since:2021-08-01 lang:pt').get_items()) :

    if i >50:
        break
    print(tweet.date.date())
    print(tweet.retweetCount)    
    print(tweet.renderedContent)

I get this:

AttributeError: 'Tweet' object has no attribute 'retweetCount'

Thanks for your help.



Solution 1:[1]

It's a problem with snscrape's version (0.3.4). After installing the development version (that is, 0.3.5.dev138+ga6b6f3f now) your code works.

To install the development version, use the command below (copy-paste from here):

$ pip3 install git+https://github.com/JustAnotherArchivist/snscrape.git
...
$ pip3 list | grep snscrape
snscrape                          0.3.5.dev138+ga6b6f3f

Solution 2:[2]

There is no Tweet.retweetCount in snscrape 0.3.4 — https://github.com/JustAnotherArchivist/snscrape/blob/v0.3.4/snscrape/modules/twitter.py

Update to the mainline, or similar appropriate version, which adds many more Tweet properties including retweetCounthttps://github.com/JustAnotherArchivist/snscrape/blob/master/snscrape/modules/twitter.py

YMMV.

Solution 3:[3]

The Error is with the version of snscrape you are using

Try using -

!pip install snscrape==0.4.3.20220106
            OR
!pip3 install snscrape==0.4.3.20220106

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nikolaos Chatzis
Solution 2
Solution 3 Ravi kumar