Registry / web-framework / streamlit-ace

streamlit-ace

JSON →
library0.1.1pypiunverified

streamlit-ace is a Streamlit component that embeds the Ace code editor, allowing users to interact with code snippets directly within their Streamlit applications. The library is currently at version 0.1.1, with its last commit in late 2021, indicating a slow release cadence and potential for compatibility considerations with recent Streamlit versions.

pip install streamlit-ace
INSTALL
IMPORT
SIG · STREAMLIT-ACE
S
streamlit-ace
web-frameworkenv0.1.1
Install
15.7s avg
Import
1333ms
Disk
446MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 1.719s · 458.5MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 15.7s · import 0.946s · 428MB
446MB installed
● package 446MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

st_ace
from streamlit_ace import st_ace

This example demonstrates how to embed the Ace editor in a Streamlit application, initialize it with content, and retrieve the user's edits. The `auto_update=True` parameter ensures that changes in the editor are immediately reflected in the Streamlit app.

import streamlit as st from streamlit_ace import st_ace st.set_page_config(layout="wide") st.title("Streamlit Ace Editor Example") initial_content = """import pandas as pd def hello_world(): print("Hello, Streamlit Ace!") hello_world() """ content = st_ace( value=initial_content, language="python", theme="dracula", keybinding="vscode", height=200, font_size=14, tab_size=4, show_gutter=True, show_print_margin=True, wrap=False, auto_update=True, # Set to True to get immediate updates readonly=False, annotations=[{"row": 0, "column": 0, "text": "Welcome to Ace!", "type": "info"}] ) st.subheader("Editor Content:") st.code(content, language="python") if st.button("Run Code (simulated)"): st.success("Code execution triggered with current content.")
Debug
Known issues
gotchaThe `streamlit-ace` library has not been updated since late 2021 (v0.1.1). While generally functional, it may exhibit styling inconsistencies or unexpected behavior with newer versions of Streamlit (e.g., Streamlit 1.x or 2.x) due to changes in Streamlit's frontend or component API.
fix
Test thoroughly with your target Streamlit version. If styling issues occur, consider using custom CSS overrides. For critical compatibility issues, exploring alternative components or implementing a custom component might be necessary.
affects: Streamlit >= 1.0
gotchaBy default, `st_ace` does not automatically update its value back to Streamlit on every keystroke (`auto_update=False`). You need to explicitly trigger an update or rely on Streamlit's rerun mechanism to fetch the latest content.
fix
Set `auto_update=True` in the `st_ace` call if you need immediate feedback (e.g., for real-time code analysis). Alternatively, ensure your Streamlit app has a button or other interactive element that triggers a rerun to fetch the editor's latest content after user edits.
affects: All
gotchaThe component's returned value is the content of the editor at the time of Streamlit's rerun. If the user modifies the editor in the browser, these changes are not immediately visible to the Python script until a new rerun occurs.
fix
To get the latest content, ensure `auto_update=True` is set, which triggers a rerun on every change (can be resource-intensive for large documents). If `auto_update=False`, add a Streamlit button (e.g., `st.button('Get Code')`) that triggers a rerun and retrieves the editor's current content.
affects: All
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'streamlit_ace'
The `streamlit-ace` package has not been installed in the current Python environment.
fix
Run `pip install streamlit-ace` in your terminal to install the required package.
NameError: name 'st_ace' is not defined
The `st_ace` function was not imported from the `streamlit_ace` package.
fix
Add `from streamlit_ace import st_ace` at the top of your Streamlit script to import the function.
TypeError: st_ace() got an unexpected keyword argument 'lang'
An invalid or misspelled keyword argument was passed to `st_ace`. For specifying the programming language, the correct argument is `language`, not `lang`.
fix
Refer to the `streamlit-ace` documentation or the quickstart example for the correct keyword arguments. In this case, change `lang='python'` to `language='python'`.
Upgrade
Version history
0.1.1latest on PyPI · released Dec 7, 2021
Audit
Dependencies
streamlitrequiredrequired to run the Streamlit component
Agent activity
5 hits · last 30 days
node
4
Resources

No resource links recorded.

streamlit-ace — pip install streamlit-ace · libregistry