Installation¶
bw_timex is a Python software package. It's available via pip and conda / mamba.
Note
bw_timex depends on Brightway25, and will install bw25-compatible versions of the bw packages. This means that it cannot be added to existing environments that are based on Brightway2, e.g., environments containing Activity Browser.
Installing bw_timex using uv¶
uv is a fast, modern Python package manager written in Rust. It's significantly faster than pip and handles dependency resolution more reliably. Installing uv is a one-liner.
Create a new project with uv:
Run your scripts with:
Or directly get started in JupyterLab:
By default, jupyter lab will start the server at http://localhost:8888/lab.
Create and activate a new virtual environment:
Install bw_timex:
Note
Fast calculations on macOS need SuiteSparse. uv manages your Python
environment, but this system-level library has to come from
Homebrew first.
Install system dependencies:
Installing bw_timex using pip¶
-
Install
pythonfrom the website, your system package manager, or Homebrew. -
Create a directory for your virtual environments, such as
C:/Users/me/virtualenvs/. -
In a console or terminal window, create a new virtual environment:
-
Activate the virtual environment. The exact syntax depends on your operating system; it will look something like:
-
Install
bw_timex:
You can also use pip to install useful libraries like jupyterlab.
Note
Fast calculations on macOS need SuiteSparse. This background library can be installed via homebrew, as shown in this section, or via conda or mamba, as shown below.
-
Install
pythonfrom Homebrew. -
Install the requirements for
SuiteSparseviahomebrew: -
In a terminal window, create a directory for your virtual environments. This can be anywhere; we will use the home directory here as an example:
-
Create and activate a virtualenv:
-
Install
bw_timex:
You can also use pip to install useful libraries like jupyterlab.
Installing bw_timex using conda or mamba¶
Prerequisites
- A working installation of
condaormamba. If you are usingconda, we recommend installing the libmamba solver. - Basic knowledge of Conda environments
Note
bw_timex's conda package can't pin platform-specific run dependencies (it's built noarch), so pypardiso - the fastest linear algebra solver for lci() - isn't installed automatically. Add it yourself, as shown below.
-
Create a new Conda environment with
bw_timex: -
Activate the environment:
-
(Optional but recommended) You can also use conda to install useful libraries like
jupyterlab:
Note
Brightway runs on macOS, but its default linear algebra library pypardiso does not. To avoid critical errors during installation that would break core functionality, a different version of Brightway (brightway_nosolver) and a different linear algebra library (scikit-umfpack) must be installed.
-
Create a new Conda environment with
bw_timex: -
Activate the environment:
-
(Optional but recommended) You can also use conda to install useful libraries like
jupyterlab:
Building background databases automatically¶
TimexLCA can build the prospective background databases a scenario names, using
premise. That needs the optional extra:
Install the extra in its own environment
premise requires numpy < 2, so installing this extra into an environment
that already runs bw_timex downgrades numpy (and with it scipy) to
the 1.x series rather than just adding a package (resolving the extra today
gives numpy 1.26.4 and scipy 1.13.1). numpy 1.26.4 also ships wheels
only up to CPython 3.12, so on Python 3.13 the install falls back to
building numpy from source, which does not compile.
Give it a separate environment on Python 3.11 or 3.12:
uv venv --python 3.12 .venv-premise
source .venv-premise/bin/activate
uv pip install "bw_timex[premise]"
Brightway projects are shared between environments, so this costs you
nothing but a second environment: build the vintages there (with
bw_timex.ensure_scenario_databases, or a TimexLCA(..., create_missing=True)
call), then run your actual calculations from your normal bw_timex
environment against the same Brightway project - it will find the databases
premise wrote by their metadata.
Building needs credentials, which bw_timex reads from the environment unless you
pass them:
| variable | needed for |
|---|---|
PREMISE_KEY |
decrypting premise's bundled IAM scenarios |
ECOINVENT_USERNAME, ECOINVENT_PASSWORD |
importing ecoinvent, if the project has none yet |