pip is the easiest way to install psutil. It is shipped by default with Python 2.7.9+ and 3.4+. For other Python versions you can install it manually.
On Linux or via wget:
wget https://bootstrap.pypa.io/get-pip.py -O - | pythonOn OSX or via curl:
python < <(curl -s https://bootstrap.pypa.io/get-pip.py)On Windows, download pip, open cmd.exe and install it:
C:\Python27\python.exe get-pip.pyPermission issues (UNIX)
The commands below assume you're running as root. If you're not or you bump into permission errors you can either:
- prepend sudo, e.g.:
sudo pip install psutil
- install psutil for your user only (not at system level):
pip install --user psutilLinux
Ubuntu / Debian:
sudo apt-get install gcc python-dev python-pipRedHat / CentOS:
pip install psutil
sudo yum install gcc python-devel python-pipIf you're on Python 3 use python3-dev and python3-pip instead.
pip install psutil
OSX
Install Xcode first, then:
pip install psutilWindows
The easiest way to install psutil on Windows is to just use the pre-compiled exe/wheel installers hosted on PYPI via pip:
C:\Python27\python.exe -m pip install psutil
If you want to compile psutil from sources you'll need Visual Studio (Mingw32 is no longer supported):
- Python 2.6, 2.7: VS-2008
- Python 3.3, 3.4: VS-2010
- Python 3.5+: VS-2015
Compiling 64 bit versions of Python 2.6 and 2.7 with VS 2008 requires Windows SDK and .NET Framework 3.5 SP1. Once installed run vcvars64.bat, then you can finally compile (see here). To compile / install psutil from sources on Windows run:
make.bat buildFreeBSD
make.bat install
pkg install python gccOpenBSD
python -m pip install psutil
export PKG_PATH="http://ftp.openbsd.org/pub/OpenBSD/`uname -r`/packages/`arch -s`/"NetBSD
pkg_add -v python gcc
python -m pip install psutil
export PKG_PATH="ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/`uname -m`/`uname -r`/All"Solaris
pkg_add -v pkgin
pkgin install python gcc
python -m pip install psutil
If cc compiler is not installed create a symlink to gcc:
sudo ln -s /usr/bin/gcc /usr/local/bin/ccInstall:
pkg install gccInstall from sources
python -m pip install psutil
git clone https://github.com/giampaolo/psutil.gitExample :
cd psutil
python setup.py install
root@dns:/home/pi # pip install psutil
Collecting psutil
Downloading psutil-5.4.1.tar.gz (408kB)
100% |████████████████████████████████| 409kB 234kB/s
Building wheels for collected packages: psutil
Running setup.py bdist_wheel for psutil ... done
Stored in directory: /root/.cache/pip/wheels/05/a2/2a/2015d6af91fb5a4cc5bcdfa9699034e2f624fc9cc5acde7ab9
Successfully built psutil
Installing collected packages: psutil
Successfully installed psutil-5.4.1
root@dns:/home/pi # ./meminfo.py
MEMORY
------
Total : 927.3M
Available : 767.2M
Percent : 17.3
Used : 80.5M
Free : 416.4M
Active : 209.9M
Inactive : 260.4M
Buffers : 30.1M
Cached : 400.3M
Shared : 25.4M
SWAP
----
Total : 100.0M
Used : 0B
Free : 100.0M
Percent : 0.0
Sin : 0B
Sout : 0B
root@dns:/home/pi #
0 comments:
Post a Comment