"No Module named: yfinance error", Included requirments.txt file

When I try to deploy my app to streamlit cloud, I’m getting the no module error.

Link: GitHub - IanP07/StockChecker: Simple Stock Checker app hosted on streamlit

There are only 2 files in my project, the main.py file and the requirments.txt file. for the requirements file, I just got the latest version of each of the modules and pasted it in, as of right now it looks like this:

yfinance==0.2.4
streamlit==1.34.0
plotly.express=0.4.1

Here is the full error message:

ModuleNotFoundError: No module named ‘yfinance’

Any help would be much appreciated, thanks!

Welcome to the community, @I_N_P! :hugs:

I believe plotly.express should be part of the plotly package. Update your requirements.txt to:

yfinance==0.2.4
streamlit==1.34.0
plotly==5.5.0

Re-deploy your app with this updated file. Hopefully, it will resolve the ModuleNotFoundError.

Let me know how it goes!

Best,
Charly

Hi Charly, thanks for the response.

Reading through my code I realized that I had misspelled the requirements.txt file, to ‘requirments.txt’. I even did it in the title of this post haha.

It’s loading now, but weirdly, when I try to input a valid date, I get an error, and no graph shows up. It still works when I run it locally, but not deployed. Here’s the full error:

────────────────────── Traceback (most recent call last) ───────────────────────

  /home/adminuser/venv/lib/python3.11/site-packages/streamlit/runtime/scriptru  

  nner/script_runner.py:600 in _run_script                                      

                                                                                

  /mount/src/stockchecker/main.py:23 in <module>                                

                                                                                

    20 if len(ticker1) > 1 and start_date != end_date:                          

    21 │   # Chart 1                                                            

    22 │   data = yf.download(ticker1, start=start_date, end=end_date)          

  ❱ 23 │   fig = px.line(data, x=data.index, y=data['Adj Close'], title=ticker  

    24 │   st.plotly_chart(fig)                                                 

    25                                                                          

    26                                                                          

                                                                                

  /home/adminuser/venv/lib/python3.11/site-packages/plotly/express/_chart_type  

  s.py:262 in line                                                              

                                                                                

     259 │   In a 2D line plot, each row of `data_frame` is represented as ver  

     260 │   a polyline mark in 2D space.                                       

     261 │   """                                                                

  ❱  262 │   return make_figure(args=locals(), constructor=go.Scatter)          

     263                                                                        

     264                                                                        

     265 line.__doc__ = make_docstring(line, append_dict=_cartesian_append_dic  

                                                                                

  /home/adminuser/venv/lib/python3.11/site-packages/plotly/express/_core.py:19  

  45 in make_figure                                                             

                                                                                

    1942 │   layout_patch = layout_patch or {}                                  

    1943 │   apply_default_cascade(args)                                        

    1944 │                                                                      

  ❱ 1945 │   args = build_dataframe(args, constructor)                          

    1946 │   if constructor in [go.Treemap, go.Sunburst, go.Icicle] and args["  

    1947 │   │   args = process_dataframe_hierarchy(args)                       

    1948 │   if constructor == "timeline":                                      

                                                                                

  /home/adminuser/venv/lib/python3.11/site-packages/plotly/express/_core.py:13  

  24 in build_dataframe                                                         

                                                                                

    1321 │   hist1d_orientation = constructor == go.Histogram or "ecdfmode" in  

    1322 │   if constructor in cartesians:                                      

    1323 │   │   if wide_x and wide_y:                                          

  ❱ 1324 │   │   │   raise ValueError(                                          

    1325 │   │   │   │   "Cannot accept list of column references or list of c  

    1326 │   │   │   )                                                          

    1327 │   │   if df_provided and no_x and no_y:                              

────────────────────────────────────────────────────────────────────────────────

ValueError: Cannot accept list of column references or list of columns for both 

`x` and `y`.

Not sure why this error is occuring, the error message that pops up on screen is:

File "/home/adminuser/venv/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 600, in _run_script
    exec(code, module.__dict__)File "/mount/src/stockchecker/main.py", line 23, in <module>
    fig = px.line(data, x=data.index, y=data['Adj Close'], title=ticker1)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/home/adminuser/venv/lib/python3.11/site-packages/plotly/express/_chart_types.py", line 262, in line
    return make_figure(args=locals(), constructor=go.Scatter)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/home/adminuser/venv/lib/python3.11/site-packages/plotly/express/_core.py", line 1945, in make_figure
    args = build_dataframe(args, constructor)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/home/adminuser/venv/lib/python3.11/site-packages/plotly/express/_core.py", line 1324, in build_dataframe
    raise ValueError(

Code all seems to be matching, the only thing I can think of is that there was a .devcontainer folder added to the github repo automatically, but I didn’t want to delete it incase it’s necessary and not causing the error

Also, not sure if this is necessary to add, but the program does work in streamlits built-in codespace editor.

Yeah just checked it again and still not displaying any graphs for whatever reason, the main issue seems to be

“Cannot accept list of column references or list of columns for both x and y”

But it works when run locally. is it an issue with downloading a module perhaps?

What if you show the data instead of plotting? Is it what you expect?

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