Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Pytrends error: failed on_status, TrendReq.trending_searches() missing 1 required positional argument: 'self'

Ask Question

I would like to get the latest Google Trends with Pytrends. I have installed a completely new system with Python 3.10.1 and Pytrends. The code is quite simple:

#pip install pytrends
from pytrends.request import TrendReq
pytrends = TrendReq.trending_searches(pn='US')
print(pytrends.head(20))

However, I still get this error message:

TypeError: TrendReq.trending_searches() missing 1 required positional argument: 'self'

I can't find any help with googeling. Do any of you have an idea what the problem is here?

I have found a solution for me. With the examples on the github page of Pytrends:

from pytrends.request import TrendReq
pytrend = TrendReq()
trending_searches_df = pytrend.trending_searches(pn = "united_states")
print(trending_searches_df.head())

I can't explain why so many tutorials on the Internet have the wrong code. But with this it works without problems.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.