Skip to content

Instantly share code, notes, and snippets.

@mohamed
Last active October 30, 2025 12:16
Show Gist options
  • Select an option

  • Save mohamed/a158eb337d2563c55a33baf60ff1caf4 to your computer and use it in GitHub Desktop.

Select an option

Save mohamed/a158eb337d2563c55a33baf60ff1caf4 to your computer and use it in GitHub Desktop.
Setting up a Python environment using uv

uv cheatsheet

Installing uv

  • Linux:

      curl -LsSf https://astral.sh/uv/install.sh | sh
    
  • Windows:

      powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
    

Making a new project with uv

uv init

Setting cache directory

setenv UV_CACHE_DIR <cache_dir>

Populate the project

uv sync

Running commands

  • Option 1:

    source .venv/bin/activate
    python myscript.py
    
  • Option 2:

    uv run myscript.py
    

Adding dependencies

uv add numpy>=2.0

Pinning python version

uv python pin 3.12.9

All-in-one

uvx --with pandas,pyarrow ipython
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment