No such file or directory error


My streamlit app is looking for the file at an absolute file path, which may not be the same as the current working directory (cwd) of my Python script
And I got an error the ‘No such file’.
my file it’s in my current working directory (cwd) and on your Github link.
please help

Steps to reproduce

Code snippet:

#!/usr/bin/env python
# coding: utf-8

# In[12]:

import pandas as pd
import as px
import plotly.graph_objs as go
import time  # to simulate a real time data, time loop

import numpy as np  # np mean, np random
import streamlit as st  # 🎈 data web app development

# In[13]:

import os

# In[16]:

import os
import streamlit as st

# Get the current working directory
cwd = os.getcwd()

# Specify the relative path to your file from the cwd
file_path = os.path.join(cwd, "C:/Users/tali/Desktop/Elad_project/streamlit_app/80123_Tali-11.txt'")

# Check if the file exists before reading it
if os.path.exists(file_path):
    with open(file_path, "r") as f:
        file_contents =
    st.write("File not found!")

# In[15]:

#import text file 
df = pd.read_csv('C:\\Users\\tali\\Desktop\\Elad_project\\streamlit_app\\80123_Tali-11.txt', sep=',' , header=None, skiprows=[0])

# In[4]:

#add headers after loading the DataFrame by directly assigning values to the df.columns attribute
df_header = pd.read_excel('C:/Users/tali/Desktop/Elad_project/streamlit_app/Copy of HeadersForFileName80123.xlsx', sheet_name='Sheet1')
headers = df_header.iloc[0, :].tolist()
df.columns = headers

# In[5]:

from IPython.display import display
import pandas as pd

# In[6]:

# Convert the 'time' column to a date-time format
df['Time'] = pd.to_datetime(df['Time'], format='%H:%M:%S %d/%m/%Y')

# In[7]:

import streamlit as st

# In[8]:

# extract 'Time' column and 'CO2' columns [1, 4, 7, 10, 13, 16]
df_co2_chart = df.iloc[:, [0, 1, 4, 7, 10, 13, 16]]

# In[9]:

# set 'Time' column as the index
df_co2_chart.set_index('Time', inplace=True)

# In[10]:

# create line chart with 'Time' on the y-axis and 'CO2' on the x-axis

# In[ ]:

If applicable, please provide the steps we should take to reproduce the error or specified behavior.

Expected behavior:

Explain what you expect to happen when you run the code above.

Actual behavior:

Explain the undesired behavior or error you see when you run the code above.
If you’re seeing an error message, share the full contents of the error message here.

Debug info

  • Streamlit version: (get it with $ streamlit version)
  • Python version: (get it with $ python --version)
  • Using Conda? PipEnv? PyEnv? Pex?
  • OS version:
  • Browser version:

Requirements file

Using Conda? PipEnv? PyEnv? Pex? Share the contents of your requirements file here.
Not sure what a requirements file is? Check out this doc and add a requirements file to your app.


  • Link to your GitHub repo:
  • Link to your deployed app:

Additional information

If needed, add any other context about the problem here.

file_path = os.path.join(cwd, "C:/Users/tali/Desktop/Elad_project/streamlit_app/80123_Tali-11.txt'")
  1. You have a typo in the filename, look at the end
  2. This line will not work anyway
  3. I don’t understand what you want to “join” with this line?
  4. It will also not work on Streamlit Cloud, because you have no access to your local filesystem.

Thank you for your reply,
Can you suggest how to write a command that would retrieve a file from my GitHub repository?"

For example, put your data files under subfolder /data in the git repo and commit and push them to github and then read them with a relative path:


This works both for local development and streamlit cloud deployment.