Get help from the marimo community

Home
Members
Jan-Hendrik Müller
J
Jan-Hendrik Müller
Offline, last seen 3 weeks ago
Joined November 25, 2024
When I run
uv run marimo edit subfolder/hello.py
and then type

Plain Text
import os
print(os.getcwd())

I'll get
Plain Text
/Users/jan-hendrik/projects/okapi

without the subfoloder.
Therefore my question: Is there a way to start marimo, so that the python cwd is directly in the subfolder?
3 comments
M
J
I just tried
uv run --python 3.11 --with marimo --with numpy --with matplotlib marimo edit --sandbox hi.py
the equivalent pattern for jupyterlab would be
uv run --python 3.13 --with jupyterlab --with numpy --with matplotlib jupyter lab
but now I'm wondering:
When I start the marimo notebook notebook, why are the packages not installed?
Currently I get the error: The following packages were not found: "matplotlib" , "numpy" (see screenshot)
50 comments
J
l
A
M
Can I style a cell so that the entire chat is visible?
Plain Text
import marimo as mo
# Define a simple echo model function
def simple_echo_model(messages, config):
    return f"You said: {messages[-1].content}"

# Create the chat UI
mo.ui.chat(
    simple_echo_model,
    prompts=["Hello", "How are you?"],
    show_configuration_controls=True
).style({"height": "900px"})

this works, but I'll still have the scroll bar at the right of the output
1 comment
M
In JupyterLab I can use a simple CounterWidget with anywidget like this.
Plain Text
import anywidget
import traitlets


class CounterWidget(anywidget.AnyWidget):
    _esm = """
    function render({ model, el }) {
      let count = () => model.get("value");
      let btn = document.createElement("button");
      btn.innerHTML = `count is ${count()}`;
      btn.addEventListener("click", () => {
        model.set("value", count() + 1);
        model.save_changes();
      });
      model.on("change:value", () => {
        btn.innerHTML = `count is ${count()}`;
      });
      el.appendChild(btn);
    }
    export default { render };
    """

    value = traitlets.Int(40).tag(sync=True)

    def set_value(self, new_value):
        """Set the value of the counter programmatically."""
        self.value = new_value

widget  = CounterWidget()
widget

Plain Text
widget.set_value(100)

and this works (screenshot 1).
When I try to do the same within a marimo notebook, then widget.set_value(100) fails.
Any idea how I can overcome this? Suggestions are very welcome!
Here's the marimo script:
Plain Text
import anywidget
import traitlets
import marimo as mo


class CounterWidget(anywidget.AnyWidget):
    _esm = """
    function render({ model, el }) {
      let count = () => model.get("value");
      let btn = document.createElement("button");
      btn.innerHTML = `count is ${count()}`;
      btn.addEventListener("click", () => {
        model.set("value", count() + 1);
        model.save_changes();
      });
      model.on("change:value", () => {
        btn.innerHTML = `count is ${count()}`;
      });
      el.appendChild(btn);
    }
    export default { render };
    """

    value = traitlets.Int(40).tag(sync=True)

    def set_value(self, new_value):
        """Set the value of the counter programmatically."""
        self.value = new_value

widget = mo.ui.anywidget(CounterWidget())

widget
1 comment
J
Hi there!
I was thinking of running marimo with napari.
In a classic notebook in VS Code, I can simply run
Plain Text
pip install "napari[pyqt5]"

Plain Text
import napari
from skimage import data

cells = data.cells3d() 
viewer = napari.view_image(cells, channel_axis=1)

and it opens the viewer for me (screenshot 1)

When I run the same notebook in marimo, I don't get any error, but the window does not pop up. Interestingly though, the napari viewer icon pops at the right side of the screen (and I also get this jumping icon animation), but when I click it, nothing happens (screenshot2). I'm on a MacBook Air M3.
4 comments
A
J