Imports not working for Multipage app

On streamlit cloud, my multipage app cannot import modules from the directory above. The error looks like:

File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/scriptrunner/", line 557, in _run_script
    exec(code, module.__dict__)
File "app/", line 5, in <module>
    import lenders.elastic as elastic

ModuleNotFoundError: No module named 'lenders'

This ran fine on my local machine, which is weird.

My repo structure looks like this:

└── pages

How should I handle the import?

Hello guys,
I have the exact same issue if try to run the app on the docker or locally. I am unable to import modules which lie outside of the streamlit app directory. But in pycharm if i setup the run configuration to include my source root it works the app is able to load and work. I have also tried adding the path into the config.toml in .streamlit folder under [server] config but still no luck

Any guidelines how to do for multi page app as the streamlit file doesn’t lie in the root directory. This is what my directory structure looks like. Please the streamlit_app is the directory for the app and I want to import functionlist as a module

Mcking, For now, I am manually adding that dir to the syspath as a workaround:


You might have done the same.

FWIW, also seeing some flakiness in session_state with multipage UI so maybe it is just not ready for prime time yet?

1 Like