Working with external surrounding project deps (with sandbox?)
Documentation is
- [x] Missing
- [ ] Outdated
- [ ] Confusing
- [ ] Not sure?
Explain in Detail
We work with notebooks within a larger project. Marimo is ideal for this, since it doesn't cause the horrendous diffs we get from Jupyter.
The outer project is managed with poetry. We don't want marimo in the general project deps, and sometimes want additional tools in a notebook for testing/analysis that aren't in project deps. Not finding docs on a good workflow for this
So far been trying out the VSCode extension and pointing it at a separate python venv with marimo installed, then manually adding the project dir to the path within the notebook. This kinda works for simple things, but is fragile and doesn't have project-specific deps. Would be ideal if a workflow/solution would work with the VSCode extension, but not a requirement
Your Suggestion for Changes
It would be great to be able to have the project deps installed and then any notebook-specific deps layered on top all in a single sandbox. Not sure if that's achievable today? Maybe with uv directly? However it's best done, this general pattern of having some notebooks for doing exploratory work within a larger project repo seems like a common patter that it'd be great to see addressed in the docs
We don't currently don't support this today. Maybe there is some magic we could do with uv's dependency groups.
The best workaround today would be calling subprocess.run(['uv', 'pip', 'install', '-r', 'requirements.txt']) or specific deps.
Another option is maybe marimo can ship mo.install() (can be fancy to include user confirmation, etc) which would hook into your user-configured package manager.
got part way there with:
import subprocess
import shutil
poetry_bin = shutil.which('poetry')
poetry_export = subprocess.Popen(
[poetry_bin, "export", "--without-hashes", "--with", "dev", "-f", "requirements.txt"],
stdout=subprocess.PIPE,
env={"POETRY_WARNINGS_EXPORT": "false"}
)
uv_bin = shutil.which('uv')
subprocess.run(
[uv_bin, "pip", "install", "--no-deps", "-r", "/dev/stdin"],
stdin=poetry_export.stdout,
check=True,
)
poetry_export.stdout.close()
poetry_export.wait()
(based loosely on https://mil.ad/blog/2024/uv-poetry-install.html )
that seems to install the packages into the sandbox:
Resolved 269 packages in 1.34s
Prepared 266 packages in 32.33s
Uninstalled 12 packages in 56ms
Installed 267 packages in 346ms
+ aiohttp==3.9.5
...
+ zipp==3.21.0
but then fails with a bunch of marimo errors that seem to be related to reloading:
Traceback (most recent call last):
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/marimo/_runtime/reload/autoreload.py", line 442, in superreload
module = reload(module)
^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/importlib/__init__.py", line 169, in reload
_bootstrap._exec(spec, module)
File "<frozen importlib._bootstrap>", line 621, in _exec
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/typing_extensions.py", line 758, in <module>
class SupportsAbs(Protocol[T_co]):
~~~~~~~~^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 376, in inner
return cached(*args, **kwds)
^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1874, in __class_getitem__
return _GenericAlias(cls, params,
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1383, in __init__
self.__parameters__ = _collect_parameters(args)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/typing_extensions.py", line 3041, in _collect_parameters
"""
NameError: name '_has_generic_or_protocol_as_origin' is not defined
Traceback (most recent call last):
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/marimo/_runtime/reload/autoreload.py", line 442, in superreload
module = reload(module)
^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/importlib/__init__.py", line 169, in reload
_bootstrap._exec(spec, module)
File "<frozen importlib._bootstrap>", line 621, in _exec
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/click/__init__.py", line 27, in <module>
from .exceptions import Abort as Abort
ImportError: cannot import name 'Abort' from 'click.exceptions' (/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/click/exceptions.py)
Fix with AI
[Search on Google](https://www.google.com/search?q=ImportError%3A%20cannot%20import%20name%20%27Abort%27%20from%20%27click.exceptions%27%20(%2Fhome%2Fgabriel%2F.cache%2Fuv%2Farchive-v0%2F5J61la12AYpwy5dgfoIpa%2Flib%2Fpython3.11%2Fsite-packages%2Fclick%2Fexceptions.py))
Error trying to reload module click: cannot import name 'Abort' from 'click.exceptions' (/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/click/exceptions.py)
Traceback (most recent call last):
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/marimo/_runtime/reload/autoreload.py", line 442, in superreload
module = reload(module)
^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/importlib/__init__.py", line 169, in reload
_bootstrap._exec(spec, module)
File "<frozen importlib._bootstrap>", line 621, in _exec
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/anyio/abc/__init__.py", line 49, in <module>
from .._core._tasks import CancelScope as CancelScope
ImportError: cannot import name 'CancelScope' from 'anyio._core._tasks' (/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/anyio/_core/_tasks.py)
Fix with AI
Search on Google
Error trying to reload module anyio.abc: cannot import name 'CancelScope' from 'anyio._core._tasks' (/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/anyio/_core/_tasks.py)
Traceback (most recent call last):
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/marimo/_runtime/reload/autoreload.py", line 442, in superreload
module = reload(module)
^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/importlib/__init__.py", line 169, in reload
_bootstrap._exec(spec, module)
File "<frozen importlib._bootstrap>", line 621, in _exec
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/anyio/streams/tls.py", line 28, in <module>
_PCTRTT = Tuple[Tuple[str, str], ...]
~~~~~^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 376, in inner
return cached(*args, **kwds)
^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1677, in __getitem__
return self.copy_with((*params, _TypingEllipsis))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1596, in copy_with
return _GenericAlias(self.__origin__, params,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1383, in __init__
self.__parameters__ = _collect_parameters(args)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/typing_extensions.py", line 3041, in _collect_parameters
"""
NameError: name '_has_generic_or_protocol_as_origin' is not defined
Fix with AI
[Search on Google](https://www.google.com/search?q=ImportError%3A%20cannot%20import%20name%20%27CancelScope%27%20from%20%27anyio._core._tasks%27%20(%2Fhome%2Fgabriel%2F.cache%2Fuv%2Farchive-v0%2F5J61la12AYpwy5dgfoIpa%2Flib%2Fpython3.11%2Fsite-packages%2Fanyio%2F_core%2F_tasks.py))
Error trying to reload module anyio.streams.tls: name '_has_generic_or_protocol_as_origin' is not defined
Traceback (most recent call last):
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/marimo/_runtime/reload/autoreload.py", line 442, in superreload
module = reload(module)
^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/importlib/__init__.py", line 169, in reload
_bootstrap._exec(spec, module)
File "<frozen importlib._bootstrap>", line 621, in _exec
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/click/formatting.py", line 12, in <module>
def measure_table(rows: t.Iterable[t.Tuple[str, str]]) -> t.Tuple[int, ...]:
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 376, in inner
return cached(*args, **kwds)
^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1593, in __getitem__
return self.copy_with(params)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1596, in copy_with
return _GenericAlias(self.__origin__, params,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1383, in __init__
self.__parameters__ = _collect_parameters(args)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/typing_extensions.py", line 3041, in _collect_parameters
"""
NameError: name '_has_generic_or_protocol_as_origin' is not defined
Fix with AI
[Search on Google](https://www.google.com/search?q=NameError%3A%20name%20%27_has_generic_or_protocol_as_origin%27%20is%20not%20defined)
Error trying to reload module click.formatting: name '_has_generic_or_protocol_as_origin' is not defined
Traceback (most recent call last):
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/marimo/_runtime/reload/autoreload.py", line 442, in superreload
module = reload(module)
^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/importlib/__init__.py", line 169, in reload
_bootstrap._exec(spec, module)
File "<frozen importlib._bootstrap>", line 621, in _exec
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/click/utils.py", line 103, in <module>
class LazyFile:
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/click/utils.py", line 180, in LazyFile
def __iter__(self) -> t.Iterator[t.AnyStr]:
~~~~~~~~~~^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 376, in inner
return cached(*args, **kwds)
^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1593, in __getitem__
return self.copy_with(params)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1596, in copy_with
return _GenericAlias(self.__origin__, params,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1383, in __init__
self.__parameters__ = _collect_parameters(args)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/typing_extensions.py", line 3041, in _collect_parameters
"""
NameError: name '_has_generic_or_protocol_as_origin' is not defined
Fix with AI
[Search on Google](https://www.google.com/search?q=NameError%3A%20name%20%27_has_generic_or_protocol_as_origin%27%20is%20not%20defined)
Error trying to reload module click.utils: name '_has_generic_or_protocol_as_origin' is not defined
Traceback (most recent call last):
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/marimo/_runtime/reload/autoreload.py", line 442, in superreload
module = reload(module)
^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/importlib/__init__.py", line 169, in reload
_bootstrap._exec(spec, module)
File "<frozen importlib._bootstrap>", line 621, in _exec
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/jedi/api/refactoring/__init__.py", line 81, in <module>
class Refactoring:
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/jedi/api/refactoring/__init__.py", line 87, in Refactoring
def get_changed_files(self) -> Dict[Path, ChangedFile]:
~~~~^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 376, in inner
return cached(*args, **kwds)
^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1593, in __getitem__
return self.copy_with(params)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1596, in copy_with
return _GenericAlias(self.__origin__, params,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1383, in __init__
self.__parameters__ = _collect_parameters(args)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/typing_extensions.py", line 3041, in _collect_parameters
"""
NameError: name '_has_generic_or_protocol_as_origin' is not defined
Fix with AI
[Search on Google](https://www.google.com/search?q=NameError%3A%20name%20%27_has_generic_or_protocol_as_origin%27%20is%20not%20defined)
Error trying to reload module jedi.api.refactoring: name '_has_generic_or_protocol_as_origin' is not defined
Traceback (most recent call last):
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/marimo/_runtime/reload/autoreload.py", line 442, in superreload
module = reload(module)
^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/importlib/__init__.py", line 169, in reload
_bootstrap._exec(spec, module)
File "<frozen importlib._bootstrap>", line 621, in _exec
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/click/exceptions.py", line 15, in <module>
param_hint: t.Optional[t.Union[t.Sequence[str], str]]
~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 376, in inner
return cached(*args, **kwds)
^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 502, in __getitem__
return self._getitem(self, parameters)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 721, in Union
return _UnionGenericAlias(self, parameters)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1383, in __init__
self.__parameters__ = _collect_parameters(args)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/typing_extensions.py", line 3041, in _collect_parameters
"""
NameError: name '_has_generic_or_protocol_as_origin' is not defined
Fix with AI
[Search on Google](https://www.google.com/search?q=NameError%3A%20name%20%27_has_generic_or_protocol_as_origin%27%20is%20not%20defined)
Error trying to reload module click.exceptions: name '_has_generic_or_protocol_as_origin' is not defined
Traceback (most recent call last):
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/marimo/_runtime/reload/autoreload.py", line 442, in superreload
module = reload(module)
^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/importlib/__init__.py", line 169, in reload
_bootstrap._exec(spec, module)
File "<frozen importlib._bootstrap>", line 621, in _exec
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py", line 76, in <module>
_version_cache: Dict[Tuple[int, int], Mapping[str, PathInfo]] = {}
~~~~~~~^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 376, in inner
return cached(*args, **kwds)
^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1593, in __getitem__
return self.copy_with(params)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1596, in copy_with
return _GenericAlias(self.__origin__, params,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1383, in __init__
self.__parameters__ = _collect_parameters(args)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/typing_extensions.py", line 3041, in _collect_parameters
"""
NameError: name '_has_generic_or_protocol_as_origin' is not defined
Fix with AI
[Search on Google](https://www.google.com/search?q=NameError%3A%20name%20%27_has_generic_or_protocol_as_origin%27%20is%20not%20defined)
Error trying to reload module jedi.inference.gradual.typeshed: name '_has_generic_or_protocol_as_origin' is not defined
Traceback (most recent call last):
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/marimo/_runtime/reload/autoreload.py", line 442, in superreload
module = reload(module)
^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/importlib/__init__.py", line 169, in reload
_bootstrap._exec(spec, module)
File "<frozen importlib._bootstrap>", line 621, in _exec
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/anyio/_core/_tasks.py", line 12, in <module>
class _IgnoredTaskStatus(TaskStatus[object]):
~~~~~~~~~~^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 376, in inner
return cached(*args, **kwds)
^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1874, in __class_getitem__
return _GenericAlias(cls, params,
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1383, in __init__
self.__parameters__ = _collect_parameters(args)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/typing_extensions.py", line 3041, in _collect_parameters
"""
NameError: name '_has_generic_or_protocol_as_origin' is not defined
Fix with AI
Search on Google
Error trying to reload module anyio._core._tasks: name '_has_generic_or_protocol_as_origin' is not defined
Traceback (most recent call last):
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/marimo/_runtime/reload/autoreload.py", line 442, in superreload
module = reload(module)
^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/importlib/__init__.py", line 169, in reload
_bootstrap._exec(spec, module)
File "<frozen importlib._bootstrap>", line 621, in _exec
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/itsdangerous/timed.py", line 26, in <module>
class TimestampSigner(Signer):
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/itsdangerous/timed.py", line 75, in TimestampSigner
) -> _t.Tuple[bytes, datetime]:
~~~~~~~~^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 376, in inner
return cached(*args, **kwds)
^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1680, in __getitem__
return self.copy_with(params)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1596, in copy_with
return _GenericAlias(self.__origin__, params,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1383, in __init__
self.__parameters__ = _collect_parameters(args)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/typing_extensions.py", line 3041, in _collect_parameters
"""
NameError: name '_has_generic_or_protocol_as_origin' is not defined
Fix with AI
[Search on Google](https://www.google.com/search?q=NameError%3A%20name%20%27_has_generic_or_protocol_as_origin%27%20is%20not%20defined)
Error trying to reload module itsdangerous.timed: name '_has_generic_or_protocol_as_origin' is not defined
Traceback (most recent call last):
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/marimo/_runtime/reload/autoreload.py", line 442, in superreload
module = reload(module)
^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/importlib/__init__.py", line 169, in reload
_bootstrap._exec(spec, module)
File "<frozen importlib._bootstrap>", line 621, in _exec
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/typing_extensions.py", line 758, in <module>
class SupportsAbs(Protocol[T_co]):
~~~~~~~~^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 376, in inner
return cached(*args, **kwds)
^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1874, in __class_getitem__
return _GenericAlias(cls, params,
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1383, in __init__
self.__parameters__ = _collect_parameters(args)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/typing_extensions.py", line 3041, in _collect_parameters
"""
NameError: name '_has_generic_or_protocol_as_origin' is not defined
Fix with AI
[Search on Google](https://www.google.com/search?q=NameError%3A%20name%20%27_has_generic_or_protocol_as_origin%27%20is%20not%20defined)
@gabrielgrant - does it work if you turn off module reloading? Its on the footer, there is: on, lazy, off. if thats fixes it, we can look into the module reload error
the cell with the install code only shows the error the first time it is run after starting the kernel (after that it is just Audited 279 packages in 2.05s); the subsequent cell where i actually try to use a package seems to fail with the same error regardless of the auto-module-reload setting (same error as many of the above, though less clear whether it is actually coming from marimo this time?):
Traceback (most recent call last):
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/marimo/_runtime/executor.py", line 157, in execute_cell
exec(cell.body, glbls)
Cell marimo://app/api/queue/notebooks/nutrient_estimation_tests_marimo.py#cell=cell-2, line 14, in <module>
from app.util.testing.notebook_helpers import init_app
File "/home/gabriel/repos/rxfood/MNT/app/util/testing/notebook_helpers.py", line 5, in <module>
from google.cloud import storage
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/google/cloud/storage/__init__.py", line 35, in <module>
from google.cloud.storage.batch import Batch
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/google/cloud/storage/batch.py", line 40, in <module>
import requests
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/requests/__init__.py", line 45, in <module>
from .exceptions import RequestsDependencyWarning
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/requests/exceptions.py", line 9, in <module>
from .compat import JSONDecodeError as CompatJSONDecodeError
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/requests/compat.py", line 30, in <module>
chardet = _resolve_char_detection()
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/requests/compat.py", line 24, in _resolve_char_detection
chardet = importlib.import_module(lib)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/charset_normalizer/__init__.py", line 24, in <module>
from .api import from_bytes, from_fp, from_path, normalize
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/charset_normalizer/api.py", line 10, in <module>
from .cd import (
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/charset_normalizer/cd.py", line 9, in <module>
from .md import is_suspiciously_successive_range
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/charset_normalizer/md.py", line 5, in <module>
from .utils import (
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/charset_normalizer/utils.py", line 250, in <module>
def identify_sig_or_bom(sequence: bytes) -> Tuple[Optional[str], bytes]:
~~~~~^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 376, in inner
return cached(*args, **kwds)
^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1680, in __getitem__
return self.copy_with(params)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1596, in copy_with
return _GenericAlias(self.__origin__, params,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.pyenv/versions/3.11.9/lib/python3.11/typing.py", line 1383, in __init__
self.__parameters__ = _collect_parameters(args)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gabriel/.cache/uv/archive-v0/5J61la12AYpwy5dgfoIpa/lib/python3.11/site-packages/typing_extensions.py", line 3041, in _collect_parameters
"""
NameError: name '_has_generic_or_protocol_as_origin' is not defined
Oh, actually I misspoke: I had been re-launching the server in its entirety before (so recreating a new sandbox), not just restarting the kernel. Just restarting the kernel (with module change tracking turned off) actually does seem to work!
Unfortunately this workaround seems to no longer be working as of 0.10.9 (I believe it was still working on 0.10.5). Still looks like the uv install is working, output is the same ("Audited 279 packages in 2.43s") but seems the packages aren't actually being resolved when importing (even after kernel restart) and they're not showing in the marimo packages pane list (which i think they were before? not 100% sure about that)
A quick glance thru the release notes doesn't point to any obvious changes to dep handling that would have affected this. (the only one that seems maybe semi-relevant is #3291 , but only tangentially so). Any idea what might have changed?
Could your uv have been upgraded? Do other versions work? You can run with uvx --with marimo==0.10.5 marimo edit
Thanks for the follow-up. It seems the issue was related to a python upgrade
details
default had been updated in one branch of the parent repo but hadn't in another, so switching between was causing issues where the deps were being installed in the wrong place/by the wrong python. Didn't totally track down all the details of what was going wrong, but rebasing to stop the swapping between default py versions seems to have fixed it.
So the workaround install code i posted above is working again
IPython has a nice feature for this use case. If you have IPython installed globally, perhaps with pipx, and you run the global IPython within an activated virtual environment, it will magically try to operate within the virtual environment, despite being installed externally.
It does print the following warning:
UserWarning: Attempting to work in a virtualenv. If you encounter problems, please install IPython inside the virtualenv.
However, I've never encountered problems with it, and it's very convenient to be able to use tools without needing to add them as project dependencies. Perhaps Marimo could learn this trick too?
Edit: This is the IPython code:
https://github.com/ipython/ipython/blob/5a3bf345ed7c78e5fab84faa81285e5fd9dfa3da/IPython/core/interactiveshell.py#L905
Maybe I'm misunderstanding the question, but cant you do this in sandbox with:
dependencies= [
"myproject@file://path/to/project"
]
Which will transitively install the deps? Maybe we can auto do this if we detect a pyproject?
I might be misunderstanding the answer, but for IPython at least it doesn't install any dependencies. It just runs with what it finds in the active virtual environment. (This is not wholly sound, but works well enough most of the time.)
I think we want to encourage people to use a sandbox where ever they can. The IPython solution is a solution, but really breaks the point of sandboxing. The following seems to work:
requires-python = ">=3.12"
dependencies = [
"myproject@file:///${PROJECT_ROOT}/path/relative/to/notebook"
]
So if you have a notebook nested in myproject/notebooks you'll want "myproject@file:///${PROJECT_ROOT}/.."
I'll update the docs, and that should close the ticket
We actually have a better solution in the docs: https://docs.marimo.io/guides/package_reproducibility/?h=sandbox#local-development-with-editable-installs
dependencies = [
"my-package",
]
[tool.uv.sources]
my-package = { path = "../", editable = true }
Thanks! That looks good.