current working directory when python file in subfolder

When I run uv run marimo edit subfolder/hello.py and then type
import os
print(os.getcwd())
import os
print(os.getcwd())
I'll get
/Users/jan-hendrik/projects/okapi
/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?
No description
2 Replies
Jan-Hendrik Müller
my current workaround:
cd subfolder
uv run marimo edit hello.py
cd subfolder
uv run marimo edit hello.py
Myles Scolnick
you would need to cd into the directory. I always use mo.notebook_dir() in all my notebooks so they are compatible wherever they are run (and when run as a script)
import marimo as mo
pl.read_csv(mo.notebook_dir() / "data" / "my.csv")
import marimo as mo
pl.read_csv(mo.notebook_dir() / "data" / "my.csv")