Pre-compiled wheels are distributed for these platforms, so you won't have to install a C compiler. All you have to do is:
pip install psutil
If wheels are not available for your platform or architecture, or you wish to build & install psutil from sources, keep reading.
On all UNIX systems you can use the install-sysdeps.sh script. This will install the system dependencies necessary to compile psutil from sources. You can invoke this script from the Makefile as:
make install-sysdeps
After system deps are installed, you can compile & install psutil with:
make build make install
...or this, which will fetch the latest source distribution from PyPI:
pip install --no-binary :all: psutil
Debian / Ubuntu:
sudo apt-get install gcc python3-dev pip install --no-binary :all: psutil
RedHat / CentOS:
sudo yum install gcc python3-devel pip install --no-binary :all: psutil
Arch:
sudo pacman -S cmake gcc python pip install --no-binary :all: psutil
Alpine:
sudo apk add gcc python3-dev musl-dev linux-headers pip install --no-binary :all: psutil
To build or install psutil from source on Windows, you need to have Visual Studio 2017. or later installed. For detailed instructions, see the CPython Developer Guide.
MinGW is not supported for building psutil on Windows.
To build directly from the source tarball (.tar.gz) on PYPI, run:
pip install --no-binary :all: psutil
If you want to clone psutil's GIT repository and build / develop locally, first install: Git for Windows and launch a Git Bash shell. This provides a Unix-like environment where
makeworks.Once inside Git Bash, you can run the usual
makecommands:make build make install
Install Xcode first:
xcode-select --install pip install --no-binary :all: psutil
pkg install python3 gcc python3 -m pip install psutil
export PKG_PATH=https://cdn.openbsd.org/pub/OpenBSD/`uname -r`/packages/`uname -m`/ pkg_add -v python3 gcc pip install psutil
Assuming Python 3.11 (the most recent at the time of writing):
export PKG_PATH="https://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/`uname -m`/`uname -r`/All" pkg_add -v pkgin pkgin install python311-* gcc12-* py311-setuptools-* py311-pip-* python3.11 -m pip install psutil
If cc compiler is not installed create a symbolic link to gcc:
sudo ln -s /usr/bin/gcc /usr/local/bin/cc
Install:
pkg install gcc pip install psutil
If you don't have pip you can install it with wget:
wget https://bootstrap.pypa.io/get-pip.py -O - | python3
...or with curl:
python3 < <(curl -s https://bootstrap.pypa.io/get-pip.py)
On Windows, download pip, open cmd.exe and install it with:
py get-pip.py
Sometimes pip is installed but it's not available in your PATH
("pip command not found" or similar). Try this:
python3 -m pip install psutil
If you want to install psutil system-wide and you bump into permission errors
either run as root user or prepend sudo:
sudo pip install psutil