## [add_ipykernel](../../scripts/add_ipykernel) Adds Python virtual environments as Jupyter ipykernel options. ## Description This script automates the creation and registration of Python environments as Jupyter kernels. It supports both conda and pip virtual environments. ## Usage ```bash ./add_ipykernel.sh ENV_NAME [--create] [--verbose] [pkg1 pkg2 ...] ``` ## Arguments - `ENV_NAME`: Name of the environment/kernel to create or use - `--create`: Create a new environment if it doesn't exist - `--verbose`: Enable detailed output - `pkg1 pkg2 ...`: Additional packages to install ## Examples ```bash # Create new conda environment and register as kernel ./add_ipykernel.sh ds_env --create python=3.11 pandas # Use existing environment ./add_ipykernel.sh ds_env --verbose # Create pip venv with specific packages ./add_ipykernel.sh myproject --create numpy scipy matplotlib ``` ## Package Manager Detection The script automatically detects the appropriate package manager: - **conda**: Used if environment exists in conda or if `environment.yml`/`conda.yaml` is present - **pip**: Used if `requirements.txt` or `pyproject.toml` exists, or if already in a virtual environment ## What It Does 1. Detects package manager (conda or pip) 2. Creates environment if `--create` flag is used 3. Activates the environment 4. Installs `ipykernel` if not present 5. Registers the environment as a Jupyter kernel with display name `Python (ENV_NAME)` ## Requirements - conda (for conda environments) OR python3 with venv (for pip environments) - Jupyter installed (for kernel registration) ## Notes - Kernels are registered in user space (`--user` flag) - After registration, the kernel appears in Jupyter as "Python (ENV_NAME)" - If environment already exists, just registers it without modifying packages