Cant import other files

i am trying to import helper funcs into my main file, but it doesnt seem to work

the file is right next to it in the repo ( henosBot/dashboard (github.com))

1 Like

Hey @henosBot,

So I dont think this would work (even locally) because you have to specify the folder of your database.py file, even though it’s being imported into another file in your website/ directory. (At least this is how I have been able to get all my other scripts working, both locally and on Sharing.)

I mocked up an example, that has the same directory structure as you do:

main_dir/ 
- an_app.py <--- my main app file
- modules/  
   - mod_1.py   # first I import this into my an app file
   - mod_2.py  # I import this into mod_1.py which is imported into an_app.py

Then in the mod_1.py file to import the mod_2.py without any module not found errors use:
import modules.mod_2 as mod

Happy Streamlit-ing!
Marisa

1 Like

Thanks, it works now

1 Like