Install & Compatibility
Where this runs
tested against v0.2.13 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
build_error
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 19.4s · import 6.416s · 442MB
469MB installed
● package 469MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
NeuroKit2
✓ import neurokit2 as nk
✗ from neurokit2 import NeuroKit2
NeuroKit2 is commonly imported as nk, not as a class. Never import 'NeuroKit2' directly.
ecg_process
✓ import neurokit2 as nk; nk.ecg_process()
✗ from neurokit2 import ecg_process
All functions are accessed via the 'nk' namespace, not imported directly.
Simulate ECG signal, process it, and compute heart rate.
import neurokit2 as nk
import numpy as np
# Simulate 5 seconds of ECG signal at 100 Hz
sampling_rate = 100
ecg_signal = nk.ecg_simulate(duration=5, sampling_rate=sampling_rate, noise=0.01)
# Process the signal
signals, info = nk.ecg_process(ecg_signal, sampling_rate=sampling_rate)
# Extract heart rate
hr = nk.ecg_rate(info, sampling_rate=sampling_rate)
print("Heart rate (BPM):", np.mean(hr))
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'neurokit2'
NeuroKit2 is not installed or installed as a different package name.
fixRun `pip install neurokit2` (note: all lowercase, no spaces).
AttributeError: module 'neurokit2' has no attribute 'ecg_simulate'
Function name typo or outdated version; 'ecg_simulate' is correct.
fixUse `nk.ecg_simulate()`. Check version: `pip show neurokit2` should be >=0.2.0.
ValueError: cannot convert float NaN to integer
Some algorithms may produce NaN values (e.g., when signal is too short).
fixEnsure the signal length is sufficient for the method. Check that `sampling_rate` matches the actual sample rate.
TypeError: ecg_process() got an unexpected keyword argument 'sampling_rate'
Older version of NeuroKit2 may not support `sampling_rate` parameter in `ecg_process()`.
fixUpdate to latest version: `pip install --upgrade neurokit2`.
Upgrade
Version history
0.2.13latest on PyPI · released Mar 2, 2026
Audit
Dependencies
numpyrequiredCore numerical operations
pandasrequiredData manipulation and storage
scipyrequiredSignal processing and statistical functions
matplotlibrequiredPlotting
scikit-learnrequiredMachine learning utilities