{"id":377,"library":"threadpoolctl","title":"Threadpoolctl","description":"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.","status":"active","version":"3.6.0","language":"python","source_language":"en","source_url":"https://github.com/joblib/threadpoolctl","tags":["threadpool","BLAS","OpenMP","scientific computing","data science"],"install":[{"cmd":"pip install threadpoolctl","lang":"bash","label":"Install via pip"},{"cmd":"conda install -c conda-forge threadpoolctl","lang":"bash","label":"Install via conda"}],"dependencies":[],"imports":[{"note":"Ensure correct import path to access threadpool_info function.","symbol":"threadpool_info","correct":"from threadpoolctl import threadpool_info"},{"note":"Ensure correct import path to access threadpool_limits function.","symbol":"threadpool_limits","correct":"from threadpoolctl import threadpool_limits"}],"quickstart":{"code":"import numpy as np\nfrom threadpoolctl import threadpool_info, threadpool_limits\n\n# Introspect threadpool information\ninfo = threadpool_info()\nfor lib in info:\n    print(f\"Library: {lib['internal_api']} ({lib['user_api']})\")\n    print(f\"  Version: {lib['version']}\")\n    print(f\"  Threads: {lib['num_threads']}\")\n    print(f\"  Path: {lib['filepath']}\")\n\n# Limit threads for BLAS\nwith threadpool_limits(limits=1, user_api='blas'):\n    a = np.random.randn(1000, 1000)\n    a_squared = a @ a","lang":"python","description":"This script demonstrates how to introspect threadpool information and limit the number of threads used by BLAS libraries using threadpoolctl."},"warnings":[{"fix":"Upgrade to Python 3.9 or later to maintain compatibility.","message":"Dropped official support for Python 3.8 in version 3.6.0.","severity":"breaking","affected_versions":"3.6.0"},{"fix":"Ensure only one OpenMP library is loaded to prevent potential issues.","message":"Using threadpoolctl with both libomp (LLVM OpenMP) and libiomp (Intel OpenMP) loaded may cause crashes or deadlocks.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Install the 'numpy' package using pip: `pip install numpy`","message":"Required package 'numpy' is not installed.","severity":"breaking","affected_versions":"All versions"},{"fix":"Install the missing package using 'pip install numpy' or ensure the package is listed in your project's 'requirements.txt' and installed.","message":"Required package 'numpy' is not found. Ensure all necessary dependencies are installed.","severity":"breaking","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-05-12T13:24:47.166Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"pip install threadpoolctl","cause":"The 'threadpoolctl' library has not been installed in the current Python environment.","error":"ImportError: No module named 'threadpoolctl'"},{"fix":"from threadpoolctl import threadpool_limits","cause":"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.","error":"AttributeError: module 'threadpoolctl' has no attribute 'threadpool_limits'"},{"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'.","cause":"'threadpoolctl' could not detect any supported threadpool-backed native libraries (like OpenBLAS, MKL, or OpenMP) loaded in the current Python process.","error":"RuntimeError: threadpoolctl cannot find any threadpool library loaded in this process"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":0,"quickstart_tag":"stale","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.04,"mem_mb":1.9,"disk_size":"17.9M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.03,"mem_mb":1.9,"disk_size":"18M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.07,"mem_mb":2.3,"disk_size":"19.7M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.07,"mem_mb":2.3,"disk_size":"20M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.06,"mem_mb":2.2,"disk_size":"11.6M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.06,"mem_mb":2.2,"disk_size":"12M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.05,"mem_mb":2.3,"disk_size":"11.2M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.07,"mem_mb":2.1,"disk_size":"12M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.04,"mem_mb":1.8,"disk_size":"17.4M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.04,"mem_mb":1.8,"disk_size":"18M"}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}}