from local_folder.my_python_script import my_function
marimo edit ...
in the folder containing local_folder
, it should work.pip install -e .
) in the root directory of the local package.from local_folder.my_python_script import my_function
from ... import ...
as if it needs to be evaluated as a UV package and then finds that it is not installed. Is there a way to swap out the import resolution to prioritise checking if the folder exists first? from local_folder.my_python_script import my_function
, and run the script from the same directory you run marimo
from, you will see the same import errormarimo
is run from the directory containing local_folder
. Does this work for you? Is your directory tree different?local_folder
into a package using UV init and adding all dependencies in that folder environment. UV automatically added the package to my marimo environment as a workspace tool. python -m marimo edit
and it'll be able to pick up your local folders.sys.path
doesn't contain the root directory but rather the directory in which the notebook was saved.|- pyproject.toml |- uv.lock |- notebooks |- notebook.py |- lib |- utils.py
def add_parent_dir_to_sys_path(): if os.getcwd() not in sys.path: sys.path.append(os.getcwd())
marimo edit --no-token
sys.path
should be set up to match what you'd get running the notebook as a script. So marimo edit foo/nb.py
matches python foo/nb.py
. Creating a new notebook from the UI is an edge case because there is no directory set initially. I can see how that's confusing UX. Not quite sure what to do about thatpythonpath
, similar to what pytest allows you to do: https://docs.marimo.io/guides/configuration/runtime_configuration/#python-path[tool.marimo.runtime] pythonpath = ["project/src"]