How to Install py-cpuinfo in Python
Get CPU info with pure Python
pip install py-cpuinfo
What is py-cpuinfo?
Get CPU info with pure Python
Py-cpuinfo gets CPU info with pure Python. Py-cpuinfo should work without any extra programs or libraries, beyond what your OS provides. It does not require any compilation(C/C++, assembly, et cetera) to use. It works with Python 3.
Quick Start
Minimal example to get started with py-cpuinfo:
import cpuinfo
print(cpuinfo.__version__)
Installation
pip (standard)
pip install py-cpuinfo
Virtual environment (recommended)
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install py-cpuinfo
pip3
pip3 install py-cpuinfo
conda
conda install -c conda-forge py-cpuinfo
Poetry
poetry add py-cpuinfo
Verify the Installation
After installing, confirm the package is available:
python -c "import cpuinfo; print(cpuinfo.__version__)"
If this prints a version number, installation succeeded. If you see a ModuleNotFoundError, see the errors section below.
Installation Errors
Common errors when installing py-cpuinfo with pip.
ModuleNotFoundError: No module named 'cpuinfo'
Cause: The package is not installed in the current Python environment.
Fix: Run pip install py-cpuinfo. If using a virtual environment, ensure it is activated first.
ModuleNotFoundError: No module named 'cpuinfo' (installed but still failing)
Cause: pip installed the package into a different Python than the one running your script.
Fix: Use python -m pip install py-cpuinfo to install into the interpreter you are running.
ImportError: cannot import name 'X' from 'cpuinfo'
Cause: The function or class does not exist in the installed version.
Fix: Check the version with pip show py-cpuinfo and upgrade with pip install --upgrade py-cpuinfo.
pip: command not found
Cause: pip is not in PATH or Python was not added to PATH during installation.
Fix: Try python -m pip install py-cpuinfo. On macOS/Linux try pip3.
PermissionError: [Errno 13] Permission denied
Cause: No write access to the system Python package directory.
Fix: Use a virtual environment, or add --user: pip install --user py-cpuinfo
SSL: CERTIFICATE_VERIFY_FAILED
Cause: pip cannot verify PyPI's SSL certificate — common behind corporate proxies.
Fix: Try: pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org py-cpuinfo
Recent Releases
| Version | Released |
|---|---|
9.0.0 latest |
2022-10-25 |
8.0.0 |
2021-04-14 |
7.0.0 |
2020-07-05 |
6.0.0 |
2020-06-11 |
5.0.0 |
2019-03-20 |
Manage py-cpuinfo
Upgrade to latest version
pip install --upgrade py-cpuinfo
Install a specific version
pip install py-cpuinfo==9.0.0
Uninstall
pip uninstall py-cpuinfo
Check what is installed
pip show py-cpuinfo