Registry / data / threadpoolctl

threadpoolctl

JSON →
library3.6.0pypypi✓ verified 29d ago

Threadpoolctl is a Python library that provides helpers to limit the number of threads used in threadpool-backed native libraries, such as BLAS and OpenMP, commonly used in scientific computing and data science. The current version is 3.6.0, released on March 13, 2025. The library is actively maintained with regular updates to support new Python versions and improve functionality.

pip install threadpoolctl
INSTALL
IMPORT
SIG · THREADPOOLCTL
T
threadpoolctl
datapythonv3.6.0
Install
1.6s avg
Import
53ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v3.6.0 · 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
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.052s · 17.9MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.6s · import 0.054s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

threadpool_info
✓ from threadpoolctl import threadpool_info
Ensure correct import path to access threadpool_info function.
threadpool_limits
✓ from threadpoolctl import threadpool_limits
Ensure correct import path to access threadpool_limits function.

This script demonstrates how to introspect threadpool information and limit the number of threads used by BLAS libraries using threadpoolctl.

import numpy as np from threadpoolctl import threadpool_info, threadpool_limits # Introspect threadpool information info = threadpool_info() for lib in info: print(f"Library: {lib['internal_api']} ({lib['user_api']})") print(f" Version: {lib['version']}") print(f" Threads: {lib['num_threads']}") print(f" Path: {lib['filepath']}") # Limit threads for BLAS with threadpool_limits(limits=1, user_api='blas'): a = np.random.randn(1000, 1000) a_squared = a @ a
Debug
Known issues
breakingDropped official support for Python 3.8 in version 3.6.0.
fix
Upgrade to Python 3.9 or later to maintain compatibility.
affects: 3.6.0
gotchaUsing threadpoolctl with both libomp (LLVM OpenMP) and libiomp (Intel OpenMP) loaded may cause crashes or deadlocks.
fix
Ensure only one OpenMP library is loaded to prevent potential issues.
affects: All versions
breakingRequired package 'numpy' is not installed.
fix
Install the 'numpy' package using pip: `pip install numpy`
affects: All versions
breakingRequired package 'numpy' is not found. Ensure all necessary dependencies are installed.
fix
Install the missing package using 'pip install numpy' or ensure the package is listed in your project's 'requirements.txt' and installed.
affects: All versions
Errors
Common errors & fixes
ImportError: No module named 'threadpoolctl'
The 'threadpoolctl' library has not been installed in the current Python environment.
fix
pip install threadpoolctl
AttributeError: module 'threadpoolctl' has no attribute 'threadpool_limits'
The 'threadpool_limits' function (and 'threadpool_info') should be imported directly from the 'threadpoolctl' package, not accessed as an attribute of the top-level module.
fix
from threadpoolctl import threadpool_limits
RuntimeError: threadpoolctl cannot find any threadpool library loaded in this process
'threadpoolctl' could not detect any supported threadpool-backed native libraries (like OpenBLAS, MKL, or OpenMP) loaded in the current Python process.
fix
Ensure that libraries like NumPy or SciPy are imported and correctly linked to a threadpool-enabled BLAS/LAPACK implementation (e.g., OpenBLAS, MKL) before using 'threadpoolctl'.
Upgrade
Version history
3.6.0latest on PyPI · released Mar 13, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
23 hits · last 30 days
node
20
OpenAI (training)
1
Resources
threadpoolctl — pip install threadpoolctl · libregistry