Could not find page in switch_page model

Hello Teams,
I have one issue when I use switch_page function and error message as below:

StreamlitAPIException: Could not find page: ‘pages\operator_page.py’. Must be the file path relative to the main script, from the directory: BBT135_E-PU_Check_System.

Traceback:

File "streamlit\runtime\scriptrunner\script_runner.py", line 535, in _run_scriptFile "\\company_sharing_folder\Projects\BBT135_E-PU_Check_System\main.py", line 258, in <module>
    st.switch_page("pages/operator_page.py")File "streamlit\runtime\metrics_util.py", line 396, in wrapped_funcFile "streamlit\commands\execution_control.py", line 154, in switch_page

My app deploy to sharing network location in my company, and net device location rename to “T” instead of folder url ("\company_sharing_folder"). I try to print abspath via os module . It prints T:\Projects\BBT135_E-PU_Check_System\main.py. Please support to find the root cause why abspath cannot work on this function.
My python version is 3.10, streamlit version is 1.30.0. Thanks very much.

Hi @seandu

The path is relative to the main script.

Windows uses "" while Linux/OSX uses “/”. Can you try replacing your forward slash / with back slash \.

Further info in the Docs page:

Hope this helps!

Hi @dataprofessor
The path parameter input in switch_page doesn’t include relative path. It just need copy down (“pages/ ***.py”), but the app still doesn’t work due to the app store in network device. I think it perhaps be about the path catching rule of Windows has gap with streamlit.

It does seem to require that the page resides in the same local folder, relative to the main app.py file.

Alternatively, you can try embedding the link in st.markdown:

st.markdown(‘[This is a link](https://your-url/)’)