Thanks to visit codestin.com
Credit goes to github.com

Skip to content

set_page_config() issue in Microsoft edge #9797

@LazerLars

Description

@LazerLars

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

Having muliple files in your app and importing them to the app.py page and then afterwards settings the set_page_config() casuses the set_page_config() to crash saying it has been called muliple times even when it haven't.
Error msg:
_StreamlitSetPageConfigMustBeFirstCommandError: set_page_config() can only be called once per app page, and must be called as the first Streamlit command in your script.

For more information refer to the docs.

Traceback:..._

So this will work
#app.py
import streamlit as st
st.set_page_config(page_title='Web App', layout="wide"

import page_somePage as pageSomePage
import page_otherPage as pageOtherPage
import page_thePage as pageThePage
import page_faq as pageFAQ

This will not work
import streamlit as st
import page_somePage as pageSomePage
import page_otherPage as pageOtherPage
import page_thePage as pageThePage
import page_faq as pageFAQ

st.set_page_config(page_title='Web App', layout="wide")

to me its seems like adding the other files where i have the import streamlit as st calls the set_page_config() even thought it not present in the file. So maybe that done under the hood.

The issues only happens in Microsoft Edge and not in the Chrome or Brave browser.

Reproducible Code Example

#THIS WILL WORK
# app.py

import streamlit as st
st.set_page_config(page_title='Web App', layout="wide")

import page_somePage as pageSomePage
import page_otherPage as pageOtherPage
import page_thePage as pageThePage
import page_faq as pageFAQ


st.sidebar.subheader('My app')
page_somePage = 'somePage'
page_otherPage = 'otherPage'
page_thePage = 'thePage'
page_faq = 'FAQ'


 
pageOptions = [page_somePage, page_otherPage, page_thePage, page_faq]

pageSelect = st.sidebar.selectbox('Select page', options=pageOptions)
st.sidebar.divider()

if pageSelect == page_somePage:
	page_somePage.showPage()
if pageSelect == page_otherPage:
	page_otherPage.showPage()
if pageSelect == page_thePage:
	page_thePage.showPage()
if pageSelect == page_faq:
	page_faq.showPage()
	
#page_somePage.py
import streamlit as st

st.header('some page')
st.write('its wedensday ma dudes')

#page_otherPage.py
import streamlit as st

st.header('other page')
st.write('its thursday ma dudes')

#page_thePage.py
import streamlit as st

st.header('the page')
st.write('its friday ma dudes')

#page_faq.py
import streamlit as st

st.header('faq page')
st.write('its faq ma dudes')
# --------------------------------------------------------------------------------
# --------------------------------------------------------------------------------
# --------------------------------------------------------------------------------
# --------------------------------------------------------------------------------
!!!!!!!!!!!!!!!!#THIS WILL NOT WORK!!!!!!!!!!!!!!
# moving the part: st.set_page_config(page_title='Web App', layout="wide")
to below the imports of my subPages files causing this error:
StreamlitSetPageConfigMustBeFirstCommandError: set_page_config() can only be called once per app page, and must be called as the first Streamlit command in your script.

For more information refer to the docs.

Traceback:

# app.py

import streamlit as st
import page_somePage as pageSomePage
import page_otherPage as pageOtherPage
import page_thePage as pageThePage
import page_faq as pageFAQ
st.set_page_config(page_title='Web App', layout="wide")

st.sidebar.subheader('My app')
page_somePage = 'somePage'
page_otherPage = 'otherPage'
page_thePage = 'thePage'
page_faq = 'FAQ'


 
pageOptions = [page_somePage, page_otherPage, page_thePage, page_faq]

pageSelect = st.sidebar.selectbox('Select page', options=pageOptions)
st.sidebar.divider()

if pageSelect == page_somePage:
	page_somePage.showPage()
if pageSelect == page_otherPage:
	page_otherPage.showPage()
if pageSelect == page_thePage:
	page_thePage.showPage()
if pageSelect == page_faq:
	page_faq.showPage()
	
#page_somePage.py
import streamlit as st

st.header('some page')
st.write('its wedensday ma dudes')

#page_otherPage.py
import streamlit as st

st.header('other page')
st.write('its thursday ma dudes')

#page_thePage.py
import streamlit as st

st.header('the page')
st.write('its friday ma dudes')

#page_faq.py
import streamlit as st

st.header('faq page')
st.write('its faq ma dudes')

Steps To Reproduce

make a streamlit project with the speicifed files and launch the app.

There is a example for how its working and how its not working.

T

Expected Behavior

that the error will not occur of StreamlitSetPageConfigMustBeFirstCommandError

Current Behavior

StreamlitSetPageConfigMustBeFirstCommandError: set_page_config() can only be called once per app page, and must be called as the first Streamlit command in your script.

For more information refer to the docs.

Traceback:

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version: 1.40.0 + 1.39.0 + 1.38.0
  • Python version: 3.11.1
  • Operating System: windows 10, linux server
  • Browser: Microsoft Edge for Business
    Version 130.0.2849.68 (Official build) (64-bit)

its works in brave and chrome..

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature:st.set_page_configRelated to `st.set_page_config` commandtype:enhancementRequests for feature enhancements or new features

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions