When I execute (copied the contents into as shown below I receive an error which doesn’t tell me much. Has anyone run into this issue? I am new to this and I appreciate someone can assist.

python --credential-file PATH-OF-CREDENTIALS-FILE --config-file PATH-OF-CONFIG-FILE --filename-prefix test_search

–Result I get --------
Traceback (most recent call last):
File “”, line 207, in
File “”, line 201, in main
for tweet in stream:
File “C:\Python37\lib\site-packages\searchtweets\”, line 140, in write_result_stream
yield from write_ndjson(_filename, stream)
File “C:\Python37\lib\site-packages\searchtweets\”, line 95, in write_ndjson
for item in data_iterable:
File “C:\Python37\lib\site-packages\searchtweets\”, line 208, in stream
File “C:\Python37\lib\site-packages\searchtweets\”, line 260, in execute_request
File “C:\Python37\lib\site-packages\searchtweets\”, line 101, in retried_func
error_message = resp.json()[“error”][“message”]
KeyError: ‘error’


I don’t have a copy of your code, but this error means that resp.json() is returning an object that does not have a property called “error”. You can try printing resp.json() and see what it actually is returning.


thank you for the suggestion. The response I get when printing resp.json() is below

{‘errors’: [{‘message’: ‘Sorry, that page does not exist’, ‘code’: 34}]}

This is the endpoint I am using in YAML


Looks like you are missing the ‘s’ in ‘errors’. But that’s not all. The value of ‘errors’ is an array. Try this:

error_message = resp.json()[“errors”][0][“message”]


After adding [0] I received the error below


This is the code I downloaded from by the way. I am executing which uses (the file I keep editing to get the correct error message)

Thanks again for the help


So, after printing more responses and a few other parameters I found out the actual error is “ERROR:searchtweets.result_stream:HTTP Error code: 404: Sorry, that page does not exist”

Double-checking the endpoint, I noticed I was missing ‘30day’ in the link. After providing the correct endpoint I am able to get the result.



I am also trying to get data from premium search API and currently using its sandbox version. But I failed to execute the code given at Can u please provide me the code that you are using to crawl the dataset. I will replace the keys and other things with mine.

Thank you


What went wrong? What did you try?


What is the error? Is the code failing or running but throwing an error?

open in PythonInstallationPath\Lib\site-packages\searchtweets and print the arguments and json response to see what the error is. something like below (around row 78)

    while True:
            resp = func(*args, **kwargs)
            print(args, kwargs) ##add these print statements
            print (resp.json())


Thanks for your reply and sorry for late response,

When I run, it is giving following error

return {**dict1, **dict2}
SyntaxError: invalid syntax

Another important point is that when we install searchtweets using pip, is not installed. It is only available with the github zip file


Actually, I am unable to understand their use description given in readme file. When I am running file, it is giving the following error

File “/usr/local/lib/python2.7/dist-packages/searchtweets/”, line 80
return {**dict1, **dict2}
SyntaxError: invalid syntax

What I have to do. I am stuck now


You have python version 2.7, you need Python 3.3 or later to run

If you have python 3.3 or higher and pip install search_tweets worked without errors then you may have multiple versions of python installed (not uncommon) so you’ll need to make sure you create a python 3 environment for this.

closed #13

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.