Can't go back to the main page

I’ve started to learn about Streamlit a few weeks ago, and I’m currently trying to create a supervisory application with it.
This is my current page structure:


As it is possible to see in the image, my main page is used as a login page.
What I’m trying to do now is to create a way for the user to go back to the login page (or even redirect the user to the login page for security reasons) using the switch_page function.

A very simple example is the one shown below: a page (into the /pages directory) containing only a button that is supposed to redirect the user to the main page (

import streamlit as st

if st.button(':leftwards_arrow_with_hook:',key="1"):

However, when I try to do this, I get the following error:

StreamlitAPIException : Could not find page: . Must be the file path relative to the main script, from the directory: pages . Only the main app file and files in the pages/ directory are supported.

What can I do to make this possible? I’ve tried different arguments in the st.switch_page function, such as “Web/”, “C:/Users/ … /”, etc. but nothing helped.

Thanks in advance!!

Hi @Storz,

First, can you verify the version of Streamlit you are on, and (if possible) upgrade to the latest version? There was an issue a few versions back with how st.switch_page handled paths, but I thought it was resolved. I just want to make sure you’re not on that particular version before diving too deeply. :smile:

Hey @mathcatsand! Thanks for you answer


I’m currently using 1.34.0 version, I upgraded it today also thinking that the issue could be related to the lib version… but the problem persists :melting_face:

I’ll try to reproduce it. Can you also verify your OS and version? (And though I doubt it will matter, browser, too just to be thorough.)

When you type streamlit run ... do you capitalize your filename in the command?

I was able to reproduce the issue on a Mac where the filename was capitalized but I used lowercase letters in the streamlit run ... command. The command line tool doesn’t seem to be case sensitive but it is once you get inside the Python environment. I’ll keep testing a bit and see if it’s the same on WIndows and such…

I’ve confirmed the problem occurs on macOS but not on Windows. I think we can consider this a bug, but fortunately, the workaround seems to be quite easy: make sure you follow the capitalization of your filename when you type out your streamlit run ... command. Let me know if that works for you. I’ll report the issue to the team. :slight_smile:

I’m in a computer with Windows 11 Pro 23H2 installed, and my application is running in Chrome v124.0.6367.119 browser.
I tested the solution you provided, using only lowercase letters, but no changes. Even tried to create a simpler project with only 2 pages (both with very simple lowercased names) to check if that the problem is in the file path, and the problem continues. This is really weird… I’ll try to run this in another Windows computer and see how it goes. If I get any results I’ll post it here!

I really appreciate all your help and support!! Thank you! (:

1 Like

Thanks for confirming this is occurring on a Windows machine and that it’s slightly different than what I can reproduce on a Mac. I’ll keep looking into it.

If you can add info to the GitHub issue I opened, that’ll be helpful to the developers to give them info to reproduce the problem in all the ways it can trigger.

I don’t have issues with switch_page, for both 1.33 and 1.34. However I am on windows 10.

Can you verify this?

Good point @ferdy.

@Storz You might try making everything lowercase to eliminate that piece for certain as a test (even though I couldn’t trigger it Windows, so maybe that’s not it). Also, try switching to other pages to confirm things are operating from the correct relative location (which I believe Ferdy’s line of questioning is hinting at).