Installing pysmo
Requirements
Pysmo needs a few packages from PyPI (NumPy, SciPy, and
others), all installed automatically. It runs on Python
3.13 and 3.14 on Linux, macOS, and Windows.
A project (recommended)
Installing packages by hand is fiddly. It means creating a virtual environment,
activating it, and running pip install for each package. It is also easy to
lose track of what is installed.
Software-development tools automate this. That helps anyone running Python, not only developers. uv creates the environment, installs Python when needed, and records each package added.
Create a project and add pysmo, plus mypy for the next chapter:
uv init my-analysis
cd my-analysis
uv add pysmo
uv add --dev mypy # tooling, separate from the code's dependencies
uv add records pysmo in pyproject.toml. It also pins the full dependency
tree in uv.lock. From those two files the environment can be rebuilt exactly,
later or on another machine. Commit both.
Run code with uv:
Elsewhere, uv sync restores the environment from those two files.
Drop the uv run prefix
direnv can activate the project environment on entering
the directory, so python, mypy, and other tools run directly. Create
.envrc:
Then run direnv allow. The environment now tracks pyproject.toml and
uv.lock automatically.
A single script
For a one-off analysis, uv can attach dependencies to a single file instead of a project directory. They go in a metadata block at the top of the script.
uv run installs the listed dependencies before running the script.
Type-checking a single-file script is less convenient: a script's inline dependencies are not visible to a separately-invoked type checker. For anything involving mypy, the project layout above is smoother.
Installing into an existing environment
To install pysmo into an environment managed another way (a virtual environment
or a conda environment), activate it and use
pip:
Prefer a virtual environment over the system Python. It needs no administrator rights and keeps each project's dependencies separate.
Pre-release and development versions
The commands above install the latest stable release. For a pre-release or the development version from GitHub: