Skip to content

Instantly share code, notes, and snippets.

@daviesian
Last active January 30, 2025 19:57
Show Gist options
  • Save daviesian/3bedc8bf3014554c75f7fd6911cbf490 to your computer and use it in GitHub Desktop.
Save daviesian/3bedc8bf3014554c75f7fd6911cbf490 to your computer and use it in GitHub Desktop.
Jupyter with uv
  1. Create a virtual environment called, e.g., my-env:

    $ uv venv my-env
    
  2. Install ipykernel into it:

    $ uv pip install -p my-env ipykernel
    
  3. Register the kernel so it will show up in Jupyter:

    $ uv run -p my-env -m ipykernel install --user --name my-env
    
  4. Run Jupyter from anywhere:

    $ uvx jupyter lab
    
  5. Install packages into the my-env virtual environment as required, and they'll turn up in your notebooks:

    $ uv pip install -p my-env pandas
    

Or

  1. uv init my-project
  2. cd my-project
  3. uv run --with jupyter jupyter lab
  4. Inside a cell, !uv add numpy, or, at the command line inside the my-project directory: uv add numpy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment