Getting an error trying to import a function from within my own directory. The app runs okay locally but gives me an issue when it is deployed?

I am running my app locally and all the imports seem to work okay. However, after deployment it looks like there is an issue importing said functions with the following error:
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/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 535, in _run_script
    exec(code, module.__dict__)File "/mount/src/stock_market_assessment/streamlit/pages/1 - WTDOLLE.py", line 12, in <module>
    from functions.generate_db import *

It looks like this issue shows up in this post but there was no resolution to this post

Github Repo
Deployed on Community Cloud

2 Likes

This looks unusual, adding your local module in the requirements which is normally for external libraries.

requirements.txt

pandas_ta
pandas
yfinance
mplfinance
Jinja2
streamlit
matplotlib
functions.generate_db

This functions.generate_db is probably the issue. Can you revise your code, make it work and exclude that line?

Noted and done. However it doesn’t look like that fixed it.

I actually had that line originally removed because I thought the same: you should only need to import external packages.

However the error I got suggested it didn’t recognize it from my code.

Does it possibly have to do with the way the folders and files are structured?

Have you tested moving the functions folder inside the streamlit folder?

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