Zero Labs
Industry News / AI

Automatic Jupyter Kernels with nb_venv_kernels

Source · Towards AI By Konrad "Stellars" Jelen

From the publisher’s feed, collected in the ZeroLabs newsroom.

Manage your virtual environment kernels with easekernel managerThe ProblemStop typing `python -m ipykernel install — user — name=…` for every environmentIf you work on multiple Python projects, you know the drill. Create a virtual environment, install dependencies, manually register it as a Jupyter kernel. Delete the environment later, and the stale kernel lingers in your list forever.nb_venv_kernels eliminates this friction. One install, and all your environments — conda, uv, and venv — appear automatically in JupyterLab’s kernel selectorpython -m venv .venvsource .venv/bin/activatepip install tensorflow ipykernelpython -m ipykernel install --user --name=my_project --display-name "My Project"This works, but every new environment needs registration. Deleted environments leave orphaned kernel specs. Conda needs nb_conda_kernels, venvs need manual registration, and uv environments are often forgotten entirely.The FixInstall nb_venv_kernelsin your JupyterLab environment:pip install nb_venv_kernelsThe extension auto-enables and discovers environments immediately. Conda environments come from conda env list. uv and venv environments are detected via pyvenv.cfg markers.Working with local environmentsModern Python development favors local, project-specific environments. Tools like uv create environments inside your project directory as .venv/. Each project stays isolated, the environment travels with the code, and deleting the project cleans everything up.cd my-projectuv venvuv pip install ipykernel pandas numpyOr with standard venv:cd my-projectpython -m venv .venvsource .venv/bin/activatepip install ipykernel pandas numpyFor local environments to appear in JupyterLab, scan your workspace:nb_venv_kernels scan ~/projectsThe scan finds environments, registers them, and cleans up stale entries. You can also register individually with custom names:nb_venv_kernels register .venv -n "My Project"The `list` command shows all environments:nb_venv_kernels listname type exists kernel path----------------------------------------------------------------------------------base conda yes yes /opt/condadata-science conda (local) yes yes /opt/conda/envs/data-sciencemy-project uv yes yes ~/projects/my-project/.venvold-project venv no no ~/projects/old-project/.venvMissing environments and kernels display in red. The output shows environment type, whether the directory exists, whether ipykernel is installed, and the path.JupyterLab IntegrationBeyond the CLI, the extension adds commands to JupyterLab’s Command Palette (Ctrl+Shift+C):- Scan for Virtual Environments — find and register environments in workspace- Refresh Kernel List — immediately update the kernel selectorThe scan opens a modal showing discovered environments with action indicators.Complete WorkflowHere’s a typical workflow for a new project:mkdir ~/projects/image-classifiercd ~/projects/image-classifieruv venvuv pip install ipykernel torch torchvisionnb_venv_kernels register .venv -n "Image Classifier"Open JupyterLab. The kernel appears in the selector, ready to use.When you’re done with the project:rm -rf ~/projects/image-classifierThat’s it. The kernelspec manager finds out and unregisters the kernel; You can still run nb_venv_kernels scanto let the environment get removed from the scanned list, but that isn’t necessary.Conda Environmentsnb_venv_kernels is a drop-in replacement for nb_conda_kernels. Conda environments are discovered automatically via — no registration needed. Just ensure ipykernel is installed:conda activate my-envconda install ipykernelConfigurationOptional settings in jupyter_server_config.py:c.VEnvKernelSpecManager.venv_only = True # Hide conda kernelsc.VEnvKernelSpecManager.name_format = "{language} [{source} env:{environment}]"c.VEnvKernelSpecManager.scan_depth = 10Links:- nb_venv_kernels on PyPI- nb_venv_kernels on GitHub- Copier Data Science Template — makes use of nb_venv_kernelsTags: Python, Jupyter, JupyterLab, Virtual Environments, Data ScienceAutomatic Jupyter Kernels with nb_venv_kernels was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.