Get help from the marimo community

U
Umar
·
U
Solved

Import Error

from langgraph.graph import StateGraph, START, END

This cell raised an exception: ModuleNotFoundError('No module named 'langgraph.graph'; 'langgraph' is not a package')

Why its looking for langgraph.graph whereas langgraph is already installed.
3 comments
C
M
U
I am deploying to gihub pages and I include an image using the github template. That is I use Image.open(mo.notebook_location() / 'public' / 'pend.png').

This works when I edit the notebook (the picture is loaded), but it does not work when I build the site (neither on github nor locally by running python scripts/build.py). The rest of the notebook works as I expected.
9 comments
M
k
Hello,

when I run marimo edit file.py, I get

[W 250314 10:58:29 manager:177] Failed to read script config: 'charmap' codec can't decode byte 0x8d in position 887: character maps to <undefined>

If I run marimo edit --sandbox file.py, it does not even run due to the error.

I get the issue (I think), but I am unable to decode where it happens.
9 comments
S
k
M
H
When I try to start by running marimo edit

this is the error that appear.
Plain Text
  File "/Users/mh/.pyenv/versions/3.10.10/lib/python3.10/site-packages/marimo/_server/utils.py", line 59, in find_free_port
    return find_free_port(next_port, attempts - 1)
  File "/Users/mh/.pyenv/versions/3.10.10/lib/python3.10/site-packages/marimo/_server/utils.py", line 59, in find_free_port
    return find_free_port(next_port, attempts - 1)
  File "/Users/mh/.pyenv/versions/3.10.10/lib/python3.10/site-packages/marimo/_server/utils.py", line 59, in find_free_port
    return find_free_port(next_port, attempts - 1)
  [Previous line repeated 97 more times]
  File "/Users/mh/.pyenv/versions/3.10.10/lib/python3.10/site-packages/marimo/_server/utils.py", line 43, in find_free_port
    raise RuntimeError("Could not find a free port")
RuntimeError: Could not find a free port


I have check my ports if marimo is running on any ports using sudo lsof -i -P | grep LISTEN, but theres none.
1 comment
M
If I paste a large chunk of code into the scratchpad the main notebook area scrolls which is annoying..
Hi team,

I don't really need help here, because I ended up using httpx and that was sufficient for my issue, but while the chat component works fine, I can't seem to be able to make the openai chatcompletions work at all. And because we can't direct it to use the openai package directly because we have specific types, I decided not to work on a solution myself... so just reporting.

Tried sandbox, 3.13, 3.12, 3.11, not a python issue. Forced reinstall, upgrade etc also nothing.

hwo to fix this?
Running openai.py ⚡

➜ URL: http://localhost:2719

[W 250311 00:39:19 file_watcher:26] watchdog is not installed, using polling file watcher
Traceback (most recent call last):
File "/Users/arthrod/.local/share/uv/python/cpython-3.12.7-macos-aarch64-none/lib/python3.12/site-packages/marimo/_runtime/executor.py", line 141, in execute_cell
exec(cell.body, glbls)
File "/Users/arthrod/tmp/marimo_28512/marimocellZBYS.py", line 1, in <module>
from openai import OpenAI
File "/Users/arthrod/.local/share/uv/python/cpython-3.12.7-macos-aarch64-none/lib/python3.12/site-packages/marimo/_output/formatters/formatters.py", line 167, in exec_module
factory.register()
File "/Users/arthrod/.local/share/uv/python/cpython-3.12.7-macos-aarch64-none/lib/python3.12/site-packages/marimo/_output/formatters/ai_formatters.py", line 49, in register
from openai.types.chat import ChatCompletion, ChatCompletionChunk
ModuleNotFoundError: No module named 'openai.types'; 'openai' is not a package
[E 250311 00:39:20 ops:302] (error_id=170b3844-933a-43a4-b935-76f716f62ef3) This cell raised an exception: ModuleNotFoundError('No module named 'openai.types'; 'openai' is not a package')
[E 250311 00:39:20 ops:302] (error_id=23237b61-afea-4948-918e-260549b23e4f) An ancestor raised an exception (ModuleNotFoundError):
[E 250311 00:39:20 ops:302] (error_id=0282ed22-40d1-46be-bd46-03d4eb949875) An ancestor raised an exception (ModuleNotFoundError):
10 comments
a
M
Plain Text
class Test():
   def __init__(self):
        self.a = 1
        self.b = 2 

import inspect

inspect.getsource(Test)


Traceback (most recent call last):
File "/Users/habib/.cache/uv/archive-v0/orE7lLvC9gKEvqF8RJqEB/lib/python3.12/site-packages/marimo/_runtime/executor.py", line 142, in execute_cell
return eval(cell.last_expr, glbls)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/folders/q1/7g9hgvc17m95t7yrvcclc75h0000gn/T/marimo_99501/marimocellZzoV.py", line 1, in <module>
inspect.getsource(Test)
File "/Users/habib/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/inspect.py", line 1285, in getsource
lines, lnum = getsourcelines(object)
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/habib/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/inspect.py", line 1267, in getsourcelines
lines, lnum = findsource(object)
^^^^^^^^^^^^^^^^^^
File "/Users/habib/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/inspect.py", line 1112, in findsource
raise OSError('could not find class definition')
OSError: could not find class definition
3 comments
C
H
Hi, I'm using the custom theme nord and I like it to follow my system light/dark mode. But when at night it goes into dark mode my altair plots have text and axes disappear. See photos. I can post this as an issue on github but wondering if this should go in the themes repo or marimo and not sure if this issue is specific to this theme... are themes responsible for handling interactions with altair?

Btw, there's also an issue with selecting code in scratchpad in dark mode which doesn't behave like inside the cells. It works fine I select the full line by double clicking (see image) but not when I select a substring, basically looks invisible.
1 comment
M
and an invalid session when trying to open a sandbox
2 comments
A
r
https://duckdb.org/docs/stable/data/json/json_functions.html#json-scalar-functions

Plain Text
CREATE TABLE example (j JSON);
INSERT INTO example VALUES
    ('{ "family": "anatidae", "species": [ "duck", "goose", "swan", null ] }');


This example straight from the docs fails with

Plain Text
ValueError
This cell raised an exception: ValueError('Invalid format specifier ' "anatidae", "species": [ "duck", "goose", "swan", null ] ' for object of type 'str'')

See the console area for a traceback.
2 comments
A
c
Hi,

I noticed that running the marimo cmd+f ignores collapsed sections (not cells I think). I don't know if this is on purpose. To be more specific, I'm talking about a section of markdown heading collapsing the cells in it, those become opaque to find feature.
3 comments
M
s
Trying to deploy my marimo SVG tutorial as gitlab pages from https://gitlab.kuleuven.be/aida-lab/teaching/g0r72a-tutorial-pythonsvg, but having an issue with dependencies. One of these dependencies is svg.py. This can be installed using uv add svg.py. To import it, you use from svg import SVG instead of from svg.py import SVG. I think this is why the error below happens.

Step 1: I first build the marimo exports like this:
Plain Text
#!/bin/bash
files=("batch_and_form.py" "data_explorer.py")

source .venv/bin/activate

for file in "${files[@]}"; do
  without_extension="${file%.*}"
  uv run marimo export html-wasm "$file" -o public/"$without_extension".html --mode run
done

deactivate


  1. git push with the following .gitlab-ci.yml:
Plain Text
pages:
  script:
    - echo "Deploying to GitLab Pages..."
  artifacts:
    paths:
      - ./public
  only:
    - main


After pushing to our institute's gitlab server, I can indeed get to the exported HTML files, but get an error:
Plain Text
Traceback (most recent call last):
File "/lib/python3.12/site-packages/marimo/_runtime/executor.py", line 141, in execute_cell exec(cell.body, glbls)
Cell marimo://notebook.py#cell=cell-0, line 3, in <module> from svg import SVG, G, Circle, PathModuleNotFoundError: No module named 'svg'


So it cannot find the svg module, even though it is in the requirements.txt as svg-py. Another page that uses D3 has no issues.

Any idea what may cause this, and how it can be fixed?
26 comments
J
M
A
Hi everyone,

I'm having the following issue: I start working on a notebook, add some stuff in the cells and then after saving they keep concatenating one after the other non-stop. I turned off the ruff on save and that continued.
17 comments
1
H
a
R
H
A
Hello!
I’ve been experiencing a bug when I have a large amount of data loaded onto my GPU. Specifically,
  • The host I’m working on is a Dell tower (with a NVIDIA GPU device) running Ubuntu 24.04.
  • The marimo notebook I’m running pulls data from a mongo host (on the order of gigabytes) and then loads this data onto device via CuPy
  • the notebook operates as expected (manipulating the data, transferring some back to host to generate plots, etc.)
  • HOWEVER, when I attempt to shut the notebook down via the red circle with an x, while the browser tab is quit out of, the marimo process continues to run from the command line, and even when I ctrl+C, the process still doesn’t quit. I have to kill -9 <pid> in order to actually stop the process. (The photos I attached are after I hit red x from the notebook editor, and then after I try to ctrl+C a few times.)
As a note, notebooks in this sensorenv environment where I'm working with solely the CPU or even fewer bytes on device memory terminate as expected.

Any thoughts on what I could be doing wrong or if this is a bug?

(Oh, and sorry for any potential misuse of dialect!)
6 comments
A
Q
Hey, I have a notebook that loads data (~1.6M rows), has some UI elements for filtering that dataset and creates some altair plots. I find that when I go from app mode to edit mode the notebook first shows as blank, then tries to render elements then crashes and finally if I refresh the page it will reconnect and display things properly

Any clue on what could be going on? How can I figure out what's the culprit here?
5 comments
M
l
Trying to change the penguins sample to use pandas instead of polars, results in This cell raised an exception: BadGzipFile('Not a gzipped file (b'sp')')
20 comments
M
l
I'm trying to run the following code snippet, whose goal is to examine a pytorch model. It should print a list of layers and tensor dimensions.

Plain Text
import torch
import torchvision
import torchlens as tl

alexnet = torchvision.models.alexnet()
x = torch.rand(1, 3, 224, 224)
model_history = tl.log_forward_pass(alexnet, x, layers_to_save='all', vis_opt='unrolled')
print(model_history)

I get the following stacktrace warning me about parallel execution being used (which is a no go for torchlens):

Plain Text
Traceback (most recent call last):
  File "/home/jacob/.venv/lib/python3.13/site-packages/marimo/_runtime/executor.py", line 141, in execute_cell
    exec(cell.body, glbls)
    ~~~~^^^^^^^^^^^^^^^^^^
  Cell marimo://lab/test.py#cell=cell-0, line 7, in <module>
    model_history = tl.log_forward_pass(alexnet, x, layers_to_save='all', vis_opt='unrolled')
  File "/home/jacob/.venv/lib/python3.13/site-packages/torchlens/user_funcs.py", line 138, in log_forward_pass
    warn_parallel()
    ~~~~~~~~~~~~~^^
  File "/home/jacob/.venv/lib/python3.13/site-packages/torchlens/helper_funcs.py", line 705, in warn_parallel
    raise RuntimeError(
    ...<3 lines>...
    )
RuntimeError: WARNING: It looks like you are using parallel execution; only run pytorch-xray in the main process, since certain operations depend on execution order.

I tried running the same snippet outside of marimo in an ipyhon REPL and there I get no such error and it works fine. It seems to be related to marimo's executor.

Is there perhaps some way to work around this?
Thanks
2 comments
d
J
added open ai, anthropic , gemini ai api keys in the marimo.toml buy when i try to generate code with ai theres a pop up says "Generate with ai failed "
1 comment
M
Caught error, error: No virtual environment found in install dependencies step
Changed from uv pip install marimo to uv pip install marimo --system removed the step error

https://github.com/marimo-team/marimo-gh-pages-template/blob/main/.github/workflows/deploy.yml#L31
2 comments
M
l
I've deployed 0.11.6, have logged in, and when I let Marimo sit there (testing out the duplication bugfix), at some point the web socket connection "fails".

I'm attaching screenshots in hope that this helps, but let me know if I can provide any additional details.

I did use the ask-docs-ai channel and it mentioned to ensure that I don't have a duplicate instance, which I don't.
15 comments
M
R
I am currently deploying Marimo programatically via FastAPI and need to get access to the user object that is set on the request when inside of a Marimo cell.

I am following the examples that have been set in the docs here https://docs.marimo.io/guides/deploying/programmatically/#authentication-middleware-example

However the code that is shown in the examples, and anything else I have tried, all result in the user being a starlette.authentication.SimpleUser object. No matter how I implement the middleware or what I set the user object in the request to I get the same result inside the marimo cell.

This happens even with the example code mentioned in the docs. I have attached the following files:
  • Screenshot of the marimo app's output
  • main.py - Fast API app
  • test.py - Marimo notebook app being run programatically
No matter what I do I cannot get the values set in request.scope["user"] to show up in the app when it is rendered. I have tried changing it from a dictionary (used in the examples) to a subclass of starlette's SimpleUser. None of it is passed through to the Marimo app.

Any insight into what I could be doing wrong would be appreciated.
10 comments
C
M
I've followed the channel posting rules but haven't seen this posted yet 🙂 . The issue I'm seeing is that cell contents seem to duplicate themselves repeatedly when my notebook is left open. It appears to only happen when I have cells set to reactive. I've attached a screenshot that shows the cell contents.

I haven't included it in the screenshot, but in the next cell, I establish a connection to my MongoDB instance using pymongo and perform a query to return results to a dataframe. I've only ran this once, then left my notebook open to sit there, and can reproduce this bug the same way every time.
10 comments
M
R
s
Hey, I can't reproduce https://marimo.io/blog/altair

I am trying to take advantage of the marimo/altair integration but the click and drag selection doesn't work out of the box for me - I'm running the latest marimo
10 comments
M
l
A
I use Loguru for log messages and up until recently, I've been able to use
Plain Text
logger.remove(None)
without issue. I then create my own formatted logger with
Plain Text
logger.add(...)
. However, for a while now (maybe a week?) I've noticed that running the remove line of code when editing the notebook just hangs. I have to restart the kernel, comment this out, and then run. I don't get the new logger format that I wanted, because I have to comment out the add() as well or have duplicate messages printed, but I can then run in edit mode. Any ideas on what changed?
2 comments
M
J
I've been losing cells when going from editing to run/app mode today, very weird, I wish I could have some code to reproduce it. For instance I had ipynb conversion switched on and I was getting some errors in the terminal:

Plain Text
  File "/Users/lucharo/Projects/ml_pipelines/.venv/lib/python3.12/site-packages/marimo/_server/export/exporter.py", line 190, in export_as_ipynb
    cell = graph.cells[cid]
           ~~~~~~~~~~~^^^^^
KeyError: 'GYoj'


Let me know if you'd like the full log
2 comments
M
l