Hi, I just wanted to try to implement “pytrends” i.e. Google Trends in my Streamlit App, but I get the following error:
‘’'Successfully installed lxml-4.6.1 pytrends-4.7.3
Why is that? Because when I try to do it locally in my Jupyter notebook, I don’t have to provide login information/credentials or anything like that, as it is the case with other APIs.
Is it possible to fix the problem?
Could you go into more detail about the obstacles you face with using pytrends in a Streamlit app? A screenshot would help too!
I was able to use pytrends in a Streamlit app to retrieve trends for a given keyword. Wasn’t able to repro the oauth issue. Here’s the sample code and what the app looks like:
import streamlit as st
import pandas as pd
import matplotlib.pyplot as plt
from pytrends.request import TrendReq
# get google trends data from keyword list
@st.cache
def get_data(keyword):
keyword = [keyword]
pytrend = TrendReq()
pytrend.build_payload(kw_list=keyword)
df = pytrend.interest_over_time()
df.drop(columns=['isPartial'], inplace=True)
df.reset_index(inplace=True)
df.columns = ["ds", "y"]
return df
# sidebar
st.sidebar.write("## Trend based on keyword")
keyword = st.sidebar.text_input("Enter a keyword", help="Look up on Google Trends")
if keyword:
df = get_data(keyword)
st.dataframe(df)
fig, ax = plt.subplots()
ax = df['y'].plot()
st.pyplot(fig)
Hi, thanks that helps a lot. Will I be able to share my streamlit app so it is runs locally on others’ machines without any code to launch the app? I want to make sure streamlit has all of the functionality I need before I continue working with it.
runs locally on others’ machines without any code to launch the app
Once you deploy your app on Streamlit sharing or a cloud provider, you can share the URL of the app with your users. Your users can open the link and directly interact with the app in their web browsers, without having to run any code nor install any additional software on their machines
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.