Skip to main content

pylsl

publish workflow PyPI version

This is the Python interface to the Lab Streaming Layer (LSL). LSL is an overlay network for real-time exchange of time series between applications, most often used in research environments. LSL has clients for many other languages and platforms that are compatible with each other.

Let us know if you encounter any bugs (ideally using the issue tracker on the GitHub project).

Installation

Prerequisites

On all non-Windows platforms and for some Windows-Python combinations, you must first obtain a liblsl shared library. See the liblsl repo documentation for further details.

Get pylsl from PyPI

  • pip install pylsl

Get pylsl from source

This should only be necessary if you need to modify or debug pylsl.

  • Download the pylsl source: git clone https://github.com/labstreaminglayer/pylsl.git && cd pylsl
  • From the pylsl working directory, run pip install ..
    • Note: You can use pip install -e . to install while keeping the files in-place. This is convenient for developing pylsl.

Usage

See the examples in src/pylsl/examples. Note that these can be run directly from the commandline with (e.g.) python -m pylsl.examples.{name-of-example}.

You can get a list of the examples with python -c "import pylsl.examples; help(pylsl.examples)"

liblsl loading

pylsl will search for liblsl first at the filepath specified by an environment variable named PYLSL_LIB, then in the package directory (default location for Windows), then finally in normal system library folders.

If the shared object is not installed onto a standard search path (or it is but can't be found for some other bug), then we recommend that you copy it to the pylsl installed module path's lib subfolder. i.e. {path/to/env/}site-packages/pylsl/lib.

  • The site-packages/pylsl path will only exist after you install pylsl in your Python environment.
  • You may have to create the lib subfolder.
  • Use python -m site to find the "site-packages" path.
  • Use cp -L on platforms that use symlinks.

Alternatively, you can use an environment variable. Set the PYLSL_LIB environment variable to the location of the library or set LD_LIBRARY_PATH to the folder containing the library. For example,

  1. PYLSL_LIB=/usr/local/lib/liblsl.so python -m pylsl.examples.{name-of-example}, or
  2. LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib python -m pylsl.examples.{name-of-example}

liblsl compatibility

pylsl and liblsl are versioned independently. Historically they shared version numbers, but that convention ended after the pylsl 1.17.x series: a pylsl version number says nothing about which liblsl release it was built against, and in general you can use the latest pylsl with the latest liblsl.

Minimum supported liblsl: 1.16.0 (i.e. pylsl.library_version() >= 116). pylsl binds lsl_create_outlet_ex unconditionally when it loads the library, and that function was introduced in liblsl 1.16.0. If an older liblsl is loaded, pylsl emits a RuntimeWarning at import time (it does not raise, in case the subset of the API you use still works).

Some features require a newer liblsl than the minimum. Where noted, pylsl detects the capability by looking for the symbol and raises NotImplementedError with an explanatory message if it is absent:

Feature Requires
StreamOutlet(..., transport_flags=...) (lsl_create_outlet_ex) liblsl >= 1.16.0 (the pylsl minimum)
transp_sync_blocking (synchronous zero-copy pushes) liblsl >= 1.18.0
pylsl.set_config_filename() / pylsl.set_config_content() liblsl >= 1.17.7
StreamInfo.reset_uid() liblsl >= 1.18.0
ContinuousResolver, chunk transfer (push_chunk/pull_chunk) present in every supported liblsl; pylsl degrades gracefully if absent
StreamInlet.pull_chunk(min_samples=...) no extra liblsl requirement (implemented in Python on top of the regular chunk pull)

Note that transp_sync_blocking is a flag value, not a symbol, so pylsl cannot detect its absence: passing it to an older liblsl will simply be ignored or misinterpreted by that library.

Which liblsl do the PyPI wheels bundle?

The platform-specific wheels (win32, win_amd64, macosx_11_0_universal2, manylinux x86_64) bundle the liblsl release named by the LSL_RELEASE / LSL_RELEASE_URL variables at the top of .github/workflows/publish-to-pypi.yml (currently v1.18.0.b3). The pure-Python none-any wheel bundles no library at all; it relies on a liblsl you install yourself (see "liblsl loading" above).

Checking at runtime

import pylsl

pylsl.library_version()  # e.g. 118 -> liblsl 1.18.x
pylsl.library_info()  # build/branch details of the loaded library
pylsl.MIN_LIBLSL_VERSION  # 116 -> the oldest liblsl this pylsl supports

For maintainers

Continuous Integration

pylsl uses continuous integration and distribution. GitHub Actions will upload a new release to pypi whenever a Release is created in GitHub.

The version number is not stored in the source tree; it is derived from the git tag by setuptools-scm (see [tool.setuptools_scm] in pyproject.toml). Creating a GitHub Release with a tag like v1.18.4 is what sets the published version. Before creating the release, review the LSL_RELEASE / LSL_RELEASE_URL variables in both .github/workflows/publish-to-pypi.yml (the liblsl bundled into the platform wheels) and .github/workflows/ci.yml (the liblsl tested against), and update the "liblsl compatibility" section above if the minimum supported liblsl changed.

Linux Binaries Deprecated

We recently stopped building binary wheels for Linux. In practice, the manylinux dependencies were often incompatible with real systems.

Manual Distribution

  1. Manual way:
    1. rm -Rf build dist *.egg-info
    2. uv build (produces the sdist and the pure-Python wheel in dist/)
    3. twine upload dist/*
    • Note: the platform-specific wheels with a bundled liblsl are produced by the publish-to-pypi GitHub Actions workflow, not by this manual path.
  2. For conda
    1. build liblsl: conda build ../liblsl/
    2. conda build .

Known Issues with Multithreading on Linux

  • At least for some versions of pylsl, it has been reported that running on Linux one cannot call pylsl functions from a thread that is not the main thread. This has been reported to cause access violations, and can occur during pulling from an inlet, and also from accessing an inlets info structure in a thread.
  • Recent tests with multithreading (especially when safeguarding library calls with locks) using Python 3.7.6. with pylsl 1.14 on Linux Mint 20 suggest that this issue is solved, or at least depends on your machine. See https://github.com/labstreaminglayer/pylsl/issues/29

Acknowledgments

Pylsl was primarily written by Christian Kothe while at Swartz Center for Computational Neuroscience, UCSD. The LSL project was funded by the Army Research Laboratory under Cooperative Agreement Number W911NF-10-2-0022 as well as through NINDS grant 3R01NS047293-06S1. pylsl is maintained primarily by Chadwick Boulay. Thanks for contributions, bug reports, and suggestions go to Bastian Venthur, David Medine, Clemens Brunner, and Matthew Grivich.

Release files for pylsl 1.18.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pylsl 1.18.4
File Size Uploaded
pylsl-1.18.4.tar.gz 43.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for pylsl 1.18.4
File
pylsl-1.18.4-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
pylsl-1.18.4-py3-none-win32.whl Python 3 none Windows x86-32 Details
pylsl-1.18.4-py3-none-manylinux_2_35_x86_64.whl Python 3 none Linux glibc 2.35+ x86-64 Details
pylsl-1.18.4-py3-none-macosx_11_0_universal2.whl Python 3 none macOS 11.0+ universal2 (ARM64, x86-64) Details
pylsl-1.18.4-py3-none-any.whl Python 3 none any Details

Total release size: 2.7 MB

Release files / pylsl-1.18.4.tar.gz

Download URL pylsl-1.18.4.tar.gz
Size 43.8 kB
Tags Source
SHA-256 checksum
How to use checksums
734497f67b76d072653398d62eec5f58b580df509e9f2d97feb20800c6aa22a8
BLAKE2b-256 checksum
How to use checksums
433f613f7379290fcb8314c7a9330dfb4f2f90b10ad9f6af406d4df5861d239d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / pylsl-1.18.4-py3-none-win_amd64.whl

Download URL pylsl-1.18.4-py3-none-win_amd64.whl
Size 333.6 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
6a05d41fe29225a50f6daa3da2d8629a6ef45c648af5291582cf6994047f2ff6
BLAKE2b-256 checksum
How to use checksums
bffa26f655989b882d5ce5a04446cd9a7266112d1f0cbbf907b6b47337146d32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / pylsl-1.18.4-py3-none-win32.whl

Download URL pylsl-1.18.4-py3-none-win32.whl
Size 295.4 kB
Tags Python 3 Windows x86-32
SHA-256 checksum
How to use checksums
5f9417c255073aaa70d83727c824c3745c02902cbcf9d6653c103794828d4382
BLAKE2b-256 checksum
How to use checksums
93f7569e0f4151721b1c8017f58bd1f1f6b588da4910c1744d6b98c7dd2e097c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / pylsl-1.18.4-py3-none-manylinux_2_35_x86_64.whl

Download URL pylsl-1.18.4-py3-none-manylinux_2_35_x86_64.whl
Size 1.3 MB
Tags Linux glibc 2.35+ x86-64 Python 3
SHA-256 checksum
How to use checksums
22df669d81dfe711b45faa9b1febe62943c87529bc71e2e17df9c6ede0f8d577
BLAKE2b-256 checksum
How to use checksums
4ef9759255d5e0b905bf3c01226c6a93a79d5a1558cdc1c3474f272f6aadefdf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / pylsl-1.18.4-py3-none-macosx_11_0_universal2.whl

Download URL pylsl-1.18.4-py3-none-macosx_11_0_universal2.whl
Size 727.5 kB
Tags Python 3 macOS 11.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
c23dc99d0c4f4f7664f7d9b05e6dc30b89c1edbbd24fb7c40cb9571730091879
BLAKE2b-256 checksum
How to use checksums
2756b1f3de55df5d63dd02ec6d2dec93411b56d08653f0c1254dbc7c58db351a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / pylsl-1.18.4-py3-none-any.whl

Download URL pylsl-1.18.4-py3-none-any.whl
Size 46.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1a3063df0145274fde1cac05dc5e2d64c8993a57db54f4b820049f63a5be692b
BLAKE2b-256 checksum
How to use checksums
56efbef70a1c24d544fd244580994b1066e4753885071c6b3bf6ee711ecacff3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

1.18.5

6 release files

This release

1.18.4 This release

6 release files

1.18.2

6 release files

1.18.1

6 release files

1.18.0

2 release files

1.17.6

4 release files

1.17.5

4 release files

1.17.4

4 release files

1.17.3

2 release files

1.17.2

2 release files

1.17.1

2 release files

1.17.0

2 release files

1.16.2

3 release files

1.16.1

3 release files

1.16.0

5 release files

1.15.0

4 release files

1.14.0

4 release files

1.13.6

4 release files

1.13.5

5 release files

1.13.4

5 release files

1.13.3

5 release files

1.13.2

5 release files

1.12.2

2 release files

1.10.5

1 release file

1.10.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page