Install¶
Installation takes about five minutes and only needs to be done once.
1. Check the Python version¶
Open a terminal (see Terminal basics) and enter:
layerbn requires Python 3.11, 3.12, 3.13 or 3.14. Python 3.15 is not yet supported. If the
output is Python 3.11.x to Python 3.14.x, continue with step 2.
Python is not found, or the version is older than 3.11 or newer than 3.14
Download and install Python 3.14 from python.org/downloads. The download button on that page can offer a newer version; select Python 3.14 under Looking for a specific release?. You can install several versions of Python next to each other.
- Windows: on the first screen of the installer, select Add python.exe to PATH. Otherwise the terminal cannot find Python.
- macOS: after the installation, open the Python folder in Applications and double-click Install Certificates.
Close the terminal, open a new one and check the version again.
python or python3
On macOS the commands are usually python3 and pip3; on Windows they are python and
pip. This documentation uses python. On macOS, use python3 instead.
2. Install layerbn¶
This installs layerbn and its dependencies, which takes one to two minutes. Git and a GitHub account are not required.
Use python3 -m pip, not pip
A computer can have more than one Python installation. On macOS, pip often belongs to
the Python 3.9 that comes with Apple's developer tools, while python3 starts a newer
version. python3 -m pip always installs into the Python that python3 starts, which is
the version you checked in step 1.
Failed to build scikit-learn, or requires a different Python: 3.15
layerbn does not yet support Python 3.15. Install Python 3.14 next to your current version, as described in step 1, and install layerbn with that version:
After installing Python 3.14, python3 may still start Python 3.15. Use
python3.14 instead of python3 in all other commands, for example
python3.14 -m layerbn --help.
ERROR: Package 'layerbn' requires a different Python: 3.9.6 not in '>=3.11'
pip belongs to an older Python installation than the one you checked in step 1. Install
with python3 -m pip instead of pip (on Windows, python -m pip), as shown above.
3. Verify the installation¶
The output lists the commands init, check, run and migrate.
If layerbn is not found, use the same command through Python. This always works:
In that case, write python3 -m layerbn (Windows: python -m layerbn) wherever this
documentation writes layerbn, for example python3 -m layerbn init my-study. Include -m.
layerbn: command not found or not recognized
layerbn is installed, but the folder where pip places commands is not on your PATH. The installation output then contains a warning such as:
WARNING: The script layerbn is installed in '/Users/name/Library/Python/3.14/bin'
which is not on PATH.
This is common on computers managed by a hospital or university, where pip installs packages in your user folder.
You can use python3 -m layerbn instead of layerbn (on Windows, python -m layerbn).
This works for every command in this documentation, for example
python3 -m layerbn init my-study. Do not omit -m: without it, Python looks for a file
named layerbn in the working folder.
To use the layerbn command itself on macOS, add the folder from the warning to your
PATH. Replace 3.14 with your Python version (the first two numbers of
python3 --version):
On Windows, the warning shows a folder such as
C:\Users\name\AppData\Roaming\Python\Python314\Scripts. Add it to the user variable
Path under Settings → System → About → Advanced system settings → Environment
Variables, and open a new terminal.
can't open file '.../layerbn': [Errno 2] No such file or directory
The -m is missing. python3 layerbn looks for a file named layerbn in the working
folder. Use python3 -m layerbn (with Python 3.14: python3.14 -m layerbn). If an empty
folder named layerbn was created, you can delete it.
layerbn: error: the following arguments are required: command
layerbn was started without a command. Check that the command was typed completely, for
example layerbn --help or layerbn init my-study, with two hyphens before help. Text
copied from an e-mail, chat or Word document can be cut off or contain changed
characters; type the command by hand. From version 3.0.1, layerbn shows the help in this
case.
error: externally-managed-environment
Some Python installations, such as Homebrew Python on macOS and the system Python on Linux, do not allow packages to be installed directly. Create a virtual environment for layerbn:
python -m venv $HOME\layerbn-env
$HOME\layerbn-env\Scripts\Activate.ps1
python -m pip install "https://github.com/umcu/layerbn/archive/refs/heads/main.zip"
If PowerShell does not allow the activation script to run, enter the following
command once and try again:
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
The prompt now starts with (layerbn-env). Run the activate command again in each new
terminal before you use layerbn.
Create the virtual environment in your home folder, as above, and not in a folder that is synchronised by OneDrive, Dropbox or iCloud. A virtual environment contains thousands of small files, which slows down synchronisation and can damage the environment.
Errors about permissions, a proxy or SSL certificates
Installation can be restricted on computers managed by a hospital or university. Add
--user to the install command. The layerbn command may then not be found; see
layerbn: command not found above. If the error persists, ask your IT department for
permission to install Python packages from PyPI and GitHub, or use a virtual environment
as described above.
Overview of installation problems¶
| Message or symptom | Cause | Solution |
|---|---|---|
Failed to build scikit-learn, or requires a different Python: 3.15 |
Python 3.15 is not yet supported | Install Python 3.14 and use python3.14 -m pip and python3.14 -m layerbn |
requires a different Python: 3.9.6 not in '>=3.11' |
pip belongs to an older Python installation |
Use python3 -m pip instead of pip |
layerbn: command not found or not recognized |
The command folder is not on PATH | Use python3 -m layerbn, or add the folder to PATH |
can't open file '.../layerbn' |
-m is missing |
Use python3 -m layerbn |
the following arguments are required: command |
No command was given | Type the full command, for example layerbn --help |
error: externally-managed-environment |
Packages cannot be installed in this Python | Use a virtual environment |
| Errors about permissions, a proxy or SSL | Restrictions on a managed computer | Add --user, or contact your IT department |
Each problem is described in the steps above. If your problem is not listed, see Error messages or report it on GitHub.
Optional packages¶
| Purpose | Command |
|---|---|
| Read Parquet files | python -m pip install pyarrow |
Read SPSS (.sav) files |
python -m pip install pyreadstat |
| Use the Jupyter notebook | python -m pip install jupyterlab |
CSV, Excel and Stata files do not require additional packages.
Updating¶
To update layerbn, run the install command with --upgrade:
Installing a specific version
The command above installs the latest version. To install a released version, replace
heads/main with tags/ followed by the version, for example tags/v3.0.0. Report the
version in your publication. It is listed at the end of each report.