What could be the problem in To-do app using Streamlit in Python?

Question:

to-dos.py

import streamlit as st
import get_todos

todos = get_todos.getTodos()

def add_todos():
    todo1 = st.session_state["new_todo"] + "n"
    todos.append(todo1)
    get_todos.writeTodos(todos)


st.title("My TO-DO App")
...

get_todos.py

def getTodos():
    with open("docs.txt", "r") as file:
        data = file.readlines()
    return data


def writeTodos(adder):
    with open("docs.txt", "w") as file:
        file.writelines(adder)


I built a TO-DO App in Python using streamlit
While performing this task in terminal, it’s continuously showing
'FileNotFoundError' meanwhile the file actually exist.

What could be the problem ?
Any syntax error? or Logical Error?

Error Traceback:
enter image description here

My project structure is shown below:
enter image description here

Asked By: Samik Pandit

||

Answers:

The main purpose of virtual environments or venv is to manage settings and dependencies of a particular project regardless of other Python projects. virtualenv tool comes bundled with PyCharm, so the user doesn’t need to install it. It is always found in the project directory named venv which should be a unique folder design to fulfil a specific purpose.

Note: No external file(s) should be added to the venv folder.

This clearly indicates that your structure is not appropriate. I will recommend you visit pycharm project structure to read more about configuration of virtual environments. You should restructure your project properly. It might feel like a pain on the neck but I bet it worth it.

Attention:
All the external files you added to venv should rather be in your samik folder which is your project main folder.

Answered By: Jamiu Shaibu