Streamlit error FileNotFoundError


Hey all!

I’m new to streamlit and I’m trying to run a web app using it. My problem is:

FileNotFoundError: [Errno 2] No such file or directory: ‘data/DadosCopaDoMundoQatar2022.xlsx’

but this file exists! I already searched the forum for this problem, and found that the solution was to include in requirements.txt the openpyxl, but that I already did, and the problem persists. I also tried different paths to the file, but unsuccessful. My code is just

import streamlit as st
from sklearn.preprocessing import MinMaxScaler 
import pandas as pd
import numpy as np
from scipy.stats import poisson

st.title('FIFA World Cup Qatar 2022™ A.I.')

teams = pd.read_excel('data/DadosCopaDoMundoQatar2022.xlsx',
                        sheet_name ='selecoes',
                        names = ['Teams_BR',
                        index_col = 0)


openpyxl==3.0.7 #or 3.0.10 (error occurs for both)

All the files are in my GitHub: Data-Science-projects/project_6 at master · SirTales/Data-Science-projects · GitHub
The data to be read is in ‘project_6/data/’, and in my experience there should be no error there.
I already tried:



and even moving the .xlsx to the same folder of (streamlit deploy) such as
pd.read_excel(‘DadosCopaDoMundoQatar2022.xlsx’) but all failed.

Thanks, in advance, for your help. And if anything else is necessary, just ask for, please!
Some infos:

  • Streamlit version: 1.15.2
  • Python version: 3.9.7
  • Ubuntu 22


Hey @SirTales, have you tried using cwd = os.getcwd() to get the current path, and then specifying the full path to the file?

1 Like

Thank you, Caroline! I was able to find the correct path for my data. It was under /app…

1 Like

Ola Sir Tales, diga como vc conseguiu resolver, explicando, estou com esse mesmo problema

Oi Fabiano!
Eu resolvi seguindo o que a colega falou. Inseri em meu as seguintes linhas:

import os
path_to_find = os.listdir()

Isso me mostrou o caminho que estavam meus dados. No meu caso, o que o comando retornou foi uma lista com os diretórios de /app/data-science-projects/ criado pelo streamlit ao rodar meu script do GitHub. Meus dados estavam em …/project_6/data/. O comando que ela sugeriu, cwd = os.getcwd() serviu para me mostrar que eu estava em uma pasta diferente da que achava que estava.