Path of '../config.yaml' file for streamlit-authenticator

I put my ‘config.yaml’ file for streamlit-authenticator at the root directory of my github repository which is same folder with the ‘main.py’ file for the app. But I’m encountering with this error. Should I change the code about the path of the ‘config.yaml’ file(‘…/config.yaml’), or do something else like adding codes into ‘requirements.txt’ file?

Error message:

Traceback (most recent call last):
  File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script
    exec(code, module.__dict__)
  File "/mount/src/project/home.py", line 12, in <module>
    with open('../config.yaml') as file:
FileNotFoundError: [Errno 2] No such file or directory: '../config.yaml'

Code of the ‘main.py’ file for the app:

import pandas as pd
import streamlit as st
import plotly as pl
from datetime import datetime
import streamlit_authenticator as stauth
import yaml
from yaml.loader import SafeLoader
with open('../config.yaml') as file:
    config = yaml.load(file, Loader=SafeLoader)

Code of the ‘requirements.txt’ file:

streamlit==1.26.0
pandas
plotly==5.16.1
streamlit-authenticator==0.2.3

Please let me know how to solve this error so that I can import the ‘config.yaml’ file successfully for the streamlit-authenticator.

with open('config.yaml') as file:

Wow! Thank you for your help! I solved that problem!

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