Installation¶
Before you install¶
Type the commands on this page in a terminal: Terminal on macOS, which is in Applications > Utilities, or PowerShell on Windows, which you can open from the Start menu.
- With uv you need only uv itself.
The uv commands on this page that install or run cgt-calc include
--python 3.12, so uv uses Python 3.12 and downloads it if needed. Keep it if you type such a command yourself: without it, uv may use an older Python it finds and install an old release of cgt-calc without an error. - With pipx or pip you need Python 3.12 or newer installed first. Check with
python3 --version, orpython --versionon Windows. With an older Python, pipx and pip also install an old release of cgt-calc without an error. cgt-calc is tested on Python 3.12, 3.13 and 3.14.
cgt-calc creates the PDF report itself. You do not need LaTeX or any other program to create it.
Install cgt-calc¶
Install the calculator with uv:
uv tool install --python 3.12 cgt-calc
Alternatively, install it with pipx:
pipx install cgt-calc
Or use pip inside an active Python virtual environment:
python -m pip install cgt-calc
Or run it directly without installing:
uvx --python 3.12 cgt-calc
If you already use Docker, you can instead run the published Docker image, which includes cgt-calc and Python.
Nix¶
The Nix community maintains a
cgt-calc package in nixpkgs:
nix run nixpkgs#cgt-calc
Check the installation¶
Run:
cgt-calc --version
If you use uvx instead of installing cgt-calc, run uvx --python 3.12 cgt-calc --version.
If the version starts with 1., it is an old release without later fixes: it was installed with a
Python older than 3.12, or installed before 2.0.0 and not upgraded since. To replace it:
- uv: run
uv tool install --python 3.12 cgt-calc@latest. - pipx: install Python 3.12 if you do not have it, then run
pipx reinstall --python python3.12 cgt-calc. On Windows, give the full path topython.exein your Python 3.12 installation in place ofpython3.12. - pip: create a new virtual environment with Python 3.12 or newer and install cgt-calc in it.
Once the command prints a version of 2.0.0 or later, choose your broker and follow the report guide.
If the command is not found¶
If installation succeeded but your terminal cannot find cgt-calc, use the step for your install
method, then try cgt-calc --version again:
- uv: run
uv tool update-shell, then open a new terminal. This adds uv's tool directory to the places your shell searches for commands; see uv's instructions. - pipx: run
pipx ensurepath, then open a new terminal. - pip: activate the same Python virtual environment you used to install cgt-calc.
Upgrade cgt-calc¶
Use the same method you used to install it:
| Install method | Upgrade command |
|---|---|
| uv | uv tool upgrade --python 3.12 cgt-calc |
| pipx | pipx upgrade cgt-calc |
| pip, in the original virtual environment | python -m pip install --upgrade cgt-calc |
Run cgt-calc --version afterwards to check the installed version. If it starts with 1., follow
the steps in Check the installation to replace it. If you use uvx, run
uvx --python 3.12 cgt-calc@latest --version to fetch and check the latest release, then use
uvx --python 3.12 cgt-calc@latest with your usual report options. Docker users should follow
Updating the image.
If you installed the unreleased version, use Update the unreleased version instead.
Install the unreleased version¶
The main branch on GitHub has changes that are not in a release yet. This code is unreleased and
may change. cgt-calc.uk shows the docs for the latest release, and
next.cgt-calc.uk shows the docs for main.
You need Git installed. Install the version on main with uv, pipx
or pip. Each command replaces a release installed with the same tool, or with pip in the same
virtual environment.
With uv:
uv tool install --python 3.12 git+https://github.com/cgt-calc/capital-gains-calculator
With pipx:
pipx install --force git+https://github.com/cgt-calc/capital-gains-calculator
With pip, inside an active Python virtual environment:
python -m pip install git+https://github.com/cgt-calc/capital-gains-calculator
Or run it without installing. uvx fetches the latest main each time:
uvx --python 3.12 --from git+https://github.com/cgt-calc/capital-gains-calculator cgt-calc
cgt-calc --version shows which code you have. For example, cgt-calc 3.0.0.post13+g327ebae is 13
commits after release 3.0.0, at commit 327ebae.
Docker users can use the edge tag instead; see Available tags. The
Nix package is built from a release, so it cannot install main.
Update the unreleased version¶
To get the latest changes on main, use the command for the tool you installed it with:
| Install method | Update command |
|---|---|
| uv | uv tool upgrade cgt-calc |
| pipx | pipx reinstall cgt-calc |
| pip, in the original virtual environment | python -m pip install --force-reinstall git+https://github.com/cgt-calc/capital-gains-calculator |
Run cgt-calc --version afterwards. The characters after +g should match the start of the latest
commit ID in the
list of commits on main.
Go back to the latest release¶
| Install method | Command |
|---|---|
| uv | uv tool install --python 3.12 cgt-calc@latest |
| pipx | pipx install --force cgt-calc |
| pip, in the original virtual environment | python -m pip install --force-reinstall cgt-calc |
Without @latest or --force, uv tool install cgt-calc and pipx install cgt-calc keep the
unreleased version. pip needs --force-reinstall: the unreleased version counts as newer than the
release it follows, so python -m pip install --upgrade cgt-calc would keep it. --force-reinstall
also reinstalls cgt-calc's dependencies.
If you used uvx --from, run uvx --python 3.12 cgt-calc@latest instead. After that,
upgrade cgt-calc as usual.
Shell completions (optional)¶
cgt-calc can generate a tab completion script for bash, zsh, fish, tcsh and PowerShell.
Create the directory and save the script for your shell:
# bash
mkdir -p ~/.local/share/bash-completion/completions
cgt-calc --print-completion bash > ~/.local/share/bash-completion/completions/cgt-calc
# zsh (the target directory must be in your $fpath)
mkdir -p ~/.zfunc
cgt-calc --print-completion zsh > ~/.zfunc/_cgt-calc
# fish
mkdir -p ~/.config/fish/completions
cgt-calc --print-completion fish > ~/.config/fish/completions/cgt-calc.fish
For PowerShell, create the completions directory if needed and generate the script:
$completionDir = "$HOME\.config\powershell\completions"
New-Item -ItemType Directory -Force $completionDir | Out-Null
cgt-calc --print-completion powershell > "$completionDir\cgt-calc.ps1"
Then add the following line to your PowerShell profile ($PROFILE):
. "$HOME\.config\powershell\completions\cgt-calc.ps1"
Regenerate the script after upgrading to pick up new options.