phy requires Python 3.10 or newer. A fresh virtual environment is recommended so that Qt and scientific Python dependencies from another project do not interfere with the GUI.
Install uv if it is
not already available, then install phy as an isolated command-line tool:
uv tool install --python 3.12 phyThis command is the same on Linux, macOS, and Windows PowerShell. uv installs
Python 3.12 if necessary, creates an environment dedicated to phy, and makes the
phy command available without manually activating that environment.
To upgrade the stable installation later:
uv tool upgrade phyPrefer an exact release number when reproducing an older workflow, a plugin setup, or an issue. Choose a release from PyPI or the GitHub releases, and check that its Python requirement is compatible with the interpreter you select.
For a persistent historical installation that does not replace your usual
phy command, create a dedicated environment. For example, to install 2.1.0:
uv venv --python 3.12 phy-2.1.0-env
uv pip install --python phy-2.1.0-env "phy==2.1.0"Activate the environment with the command printed by uv venv, then verify it:
phy --versionOn Linux and macOS this is normally source phy-2.1.0-env/bin/activate; on
Windows PowerShell it is normally .\phy-2.1.0-env\Scripts\Activate.ps1.
Use a distinct environment for each version you need to retain. This keeps old
dependencies separate from the current release and makes a result easier to
reproduce.
If you deliberately want the historical release to replace an existing
uv tool installation, use an exact pin and --force instead:
uv tool install --force --python 3.12 "phy==2.1.0"Run uv tool install --force --python 3.12 phy to restore the latest stable
release later. The tool installation has one phy command, so this option does
not keep both versions available at once.
If you prefer Python's standard environment tools, create and activate a virtual environment before installing phy.
On Linux and macOS:
python3 -m venv phy-env
source phy-env/bin/activate
python -m pip install --upgrade pip
python -m pip install phyOn Windows PowerShell:
py -3.12 -m venv phy-env
.\phy-env\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install phyIf PowerShell prevents activation, either adjust its execution policy for your
user or run .\phy-env\Scripts\python.exe -m pip install phy followed by
.\phy-env\Scripts\phy.exe --version.
To upgrade this pip installation later, activate its environment and run
python -m pip install --upgrade phy.
After either installation method:
phy --version
phy --helpThe first command prints the installed phy version. The second should list
commands including template-gui and template-describe.
Use this installation when testing an unreleased fix or developing phy. It installs editable checkouts of both phylib and phy, with each repository initially on its current default branch. An editable install uses the Python code in the checkout, so code edits take effect without building a new package.
Choose a parent directory where the two repositories and the virtual environment can live side by side.
mkdir phy-source
cd phy-source
git clone https://github.com/cortex-lab/phylib.git
git clone https://github.com/cortex-lab/phy.git
cd phy
uv sync --dev
uv pip install --editable ../phylibuv sync creates phy/.venv, installs phy editably, and installs the locked
development dependencies. The final command replaces the released phylib
package with the sibling source checkout.
New-Item -ItemType Directory phy-source
Set-Location phy-source
git clone https://github.com/cortex-lab/phylib.git
git clone https://github.com/cortex-lab/phy.git
Set-Location phy
uv sync --dev
uv pip install --editable ..\phylibThese commands create the same editable development environment as the Linux and macOS instructions.
This capability currently requires the latest phylib source; released phylib 2.7.1 does not include it. After installing the source checkouts above, install SpikeInterface into the same environment:
uv pip install --editable "../phylib[spikeinterface]"
uv run --no-sync phy template-gui /path/to/output/params.pyIn PowerShell, the editable path can also be written as
"..\phylib[spikeinterface]". Use uv run --no-sync after the override;
ordinary uv run or uv sync can restore the released phylib from the lockfile.
After syncing, reinstall the editable override before using this feature.
See SpikeInterface recordings for the
input format and channel mapping requirements. For a recording without a sorting
export, use uv run --no-sync phy trace-gui /path/to/recording.json or supply a
saved .zarr recording directory.
Run the following commands from either operating system:
uv run --no-sync phy --version
uv pip show phy phylib
git log -1 --oneline
git -C ../phylib log -1 --onelineFor both packages, uv pip show should include an Editable project location
pointing to the checkout you just cloned. The Git commands identify the exact
commits being used. Development builds of phy may also show a development
version or Git suffix in phy --version.
Save or commit your own source changes before updating. From the phy checkout:
git -C ../phylib pull --ff-only
git pull --ff-only
uv sync --dev
uv pip install --editable ../phylibIn Windows PowerShell, ../phylib may also be written as ..\phylib.
Re-running the sync picks up lockfile and package metadata changes, while the
last command ensures the sibling phylib checkout remains installed.
The locked development environment uses released phylib 2.7.1 or newer. To reproduce the CI environment, run these commands from the phy checkout:
uv sync --frozen --dev
uv run --frozen pytest phy/cluster/tests/test_selection.pyReplace the example test path with the tests relevant to your change. For broad GUI, application, or data-model changes, run:
make test-fullmake test-full includes lint and formatting checks. Tests default to Qt's
offscreen platform; Linux GUI tests also need the display and OpenGL setup
recorded in the CI workflow. Use uv run --no-sync and
make test-full UV_RUN="uv run --no-sync" when intentionally preserving an
editable phylib source override. After another uv sync, reinstall that override.
The Template GUI opens a spike-sorting output described by a params.py file:
phy template-describe /path/to/output/params.py
phy template-gui /path/to/output/params.pytemplate-describe is a useful non-GUI check before the first launch. See
Preparing a dataset if phy cannot load the output, or
Quickstart for a guided first session.
The Template GUI is the recommended workflow for current template-based sorters.
The legacy Kwik GUI needs additional packages. Install them in a separate
uv-managed environment because klustakwik2 needs NumPy, setuptools, and Cython
available while it builds:
uv venv --python 3.12 phy-kwik-env
uv pip install --python phy-kwik-env phy klusta cython
uv pip install --python phy-kwik-env --no-build-isolation klustakwik2Activate the environment using the command printed by uv venv. It can then be
opened with phy kwik-gui path/to/file.kwik.