New Streamlit Release: 0.50.2

Highlights:

  • :woman_student: SymPy support and ability to draw mathematical expressions using LaTeX! See st.latex, st.markdown, and st.write.
  • :sunrise_over_mountains: You can now set config options using environment variables. For example,
    export STREAMLIT_SERVER_PORT=9876.
  • :cat: Ability to call streamlit run directly with Github and Gist URLs. No
    need to grab the β€œraw” URL first!
  • :page_with_curl: Cleaner exception stack traces. We now remove all Streamlit-specific code
    from stack traces originating from the user’s app.

More info

Math support

WIth this release you can draw mathematical expressions in your Streamlit apps in 3 different ways:

  1. You can pass SymPy expressions to st.write and st.latex:

    a, b, c, x = sympy.symbols('a b c x')
    st.write(a * x ** 2 + b * x + c)
    
  2. You can pass LaTeX strings to st.latex:

    st.latex('ax^2 + bx + c')
    
  3. You can pass LaTeX strings in st.write, st.markdown, and magic by wrapping them in $ or $$ (to print it large in a new line):

    st.write("""
    This is a polynomial: $x^2$
    
    And so is this:
    
    $$
    ax^2 + bx + c
    $$
    """)
    

Environment variables

Streamlit supports all sorts of config options (run streamlit config show to see all of them), and you can pass them to Streamlit in different ways:

  • Via ~/.streamlit/config.toml
  • Via ./.streamlit/config.toml
  • Via command-line flags, such as in
    $ streamlit run --server.port=9876 foo.py
    
  • And now via environment variables, like this:
    $ export STREAMLIT_SERVER_PORT=9876
    $ streamlit run foo.py
    

That is, just add STREAMLIT_ before any config option and turn it to uppercase snake case and it’s a valid environment variable :smiley:

:pray: :100: Many thanks to Streamlit user @kinghuang for the contribution!!!

Github/Gist URLs:

Prior to this release, you could already call streamlit run [some_url], but that URL had to resolve to a Python file or it would be an error. Now, with the help of Streamlit user @aritropaul (:pray: :100:) we also support Github and Gist URLs.

Try it out with:

$ streamlit run https://gist.github.com/tvst/713f5804ab45b9430866ee639d8568f1
12 Likes

Hmmm, there is a bug with the st.write function and centered/one-line latex.

I have this http://167.86.86.136:8501/ running at the moment, but only the first latex line is centered, and not the two others?

Hey @peterstorm! Thanks for the heads up.

Can you share a code snippet? I can’t reproduce the bug on my machine

Also, just to clarify: the bug is that the equations below aren’t centering, right?

Correct, and I figured it out :slight_smile:

In other frameworks you are fine to enclose your latex code with $$latex_term$$ but it seems you have to make newlines in streamlit, which is completely fint, but like this:

$$
latex_term
$$
1 Like

Hi, can anyone help me with this LaTeX issue?