ModuleNotFoundError: No module named plotly.graph_objs

Hi Community,
I’m getting this " ModuleNotFoundError: This app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs (if you’re on Streamlit Cloud, click on ‘Manage app’ in the lower right of your app).

Traceback:

File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
    exec(code, module.__dict__)File "/app/stocks/app.py", line 5, in <module>
    import plotly.graph_objs as go
```"

While executing the below code:
# Search for the stock symbol
stock_symbol = search_symbol(symbol)
if stock_symbol:
    for i in stock_symbol:
        if i:
            st.write(f"Checking for {i}...")
            breakout, current_date, price_data = check_breakout(i, interval=interval.lower(), n=10)
            # sleep(2)
            if price_data is not None:
                if breakout:
                    st.write(f"{i} is about to give a {interval} breakout!")
                if i not in breakout_stocks:
                    breakout_stocks.append(i)  # add the symbol to the list of breakout stocks
                st.session_state['breakout_stocks'] = breakout_stocks  # update the list in session state
                fig = px.line(price_data, x=price_data.index, y=['Open', 'High', 'Low', 'Close'], 
                              title=f"{i} Stock Price")
                fig.update_layout(xaxis_title="Date", 
                                  yaxis_title="Price", 
                                  xaxis_rangeslider_visible=False,
                                  hovermode='x unified',
                                  height=600
                                 )

                candlestick = go.Candlestick(x=price_data.index,
                                             open=price_data['Open'],
                                             high=price_data['High'],
                                             low=price_data['Low'],
                                             close=price_data['Close'])

                fig.add_trace(candlestick)

                df = pd.DataFrame({'Latest Date' : current_date, 'Breakout Companies': breakout_stocks})
                st.table(df)
                st.plotly_chart(fig, theme="streamlit",sharing="streamlit", use_container_width=True)
            else:
                st.warning(f"{i} is not about to give a {interval} breakout.")
                continue
        else:
            st.warning(f"{i} is not about to give a {interval} breakout.")
else:
    st.warning(f"No stock about to give a {interval} breakout.")

I've already mentioned plotly==5.14.1 in the requirements.txt file, still I'm getting the same error.

Any idea? how can I fix this?

Then it is not installed. Maybe a typo or wrong path.
But without seeing the github repo, we can only guess.

Please find github repo: “https://github.com/jarihant130/stocks/blob/main/app.py

Does not exist or is private project

Check now…

It’s working now…Thanks for your quick help!!!

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