What happens when importing lamindb and the instance is not yet setup?¶
# !pip install 'lamindb[jupyter]'
import lamindb as ln
import pytest
! To use lamindb, you need to connect to an instance.
Connect to an instance: `ln.connect()`. Init an instance: `ln.setup.init()`.
If you used the CLI to set up lamindb in a notebook, restart the Python session.
If you try to use lamindb, it will raise an InstanceNotSetupError
and ask you to init
or load
an instance via the python API.
ln.setup.init(storage="./testsetup")
→ initialized lamindb: testuser1/testsetup
Now we can access functionality:
ln.track("2lhqA4uTKSFP0000")
→ created Transform('2lhqA4uTKSFP0000'), started new Run('lHiAyTra...') at 2025-07-15 12:57:31 UTC
→ notebook imports: lamindb==1.8.0 pytest==8.4.1
Let us try to init another instance in the same Python session: It doesn’t work.
# from lamindb_setup._init_instance import CannotSwitchDefaultInstance
# with pytest.raises(CannotSwitchDefaultInstance):
# ln.setup.init(storage="./testsetup2")
!lamin delete --force testsetup
• deleting instance testuser1/testsetup