FileNotFoundError: [Errno 2] No such file or directory: 'static/player_stats_initial.csv'

def analyze_using_old_season_data(max_players_from_team, transfer, wildcard, gw, budget):
player_df = pd.read_csv(‘static/player_stats_initial.csv’)
teams_df = pd.read_csv(‘static/teams.csv’)
injured_players_df = get_injured_player_list()

Hello @Manandeep_Singh, welcome to the forum!

Is your static folder located at the same location as your streamlit app script?

Yes it is located in the same location

And do you run streamlit in the same directory as well? (streamlit run app.py)
Or have you configured your PyCharm to run it for you?

In case you configured your run action, make sure you set your pythonProject as a working directory.

I run the app from anaconda


The error here is that you don’t run streamlit from your project path. When you do your streamlit run in the first screenshot, your working directory is C:/Users/HP. Therefore, when pandas tries to access static/player_stats_initial.csv, it’ll search that static directory in C:/Users/HP.

What you could do is go to your project directory, and run your app from there

> cd C:/Users/HP/PycharmProjects/pythonProject
> streamlit run app.py

Regarding the exception in your screenshot, you might have changed your source code since then, but the path is misformatted. If you want to hardcode a path in your code, make sure to use regular slashes / instead of backslashes \, or prepend your string with a little r like so: pd.read_csv(r'C:\Users\HP\...')

Curiously the csv path seems to be misformatted. That would explain the FileNotFoundError here, but i