8

我正在尝试在我的树莓派上安装 psutil,但我似乎无法开始工作。如果我执行 pip install 我会收到此错误:

psutil/_psutil_linux.c:10:20: fatal error: Python.h: No such file or directory

compilation terminated.

error: command 'gcc' failed with exit status 1

----------------------------------------
Command /usr/bin/python -c "import
setuptools;__file__='/home/pi/build/psutil/setup.py';exec(compile(open(__file__).read().replace('\r\n ', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-V39ila-record/install-record.txt failed with error code 1 in /home/pi/build/psutil
Storing complete log in /root/.pip/pip.log

如果我从安装文件的目录尝试 python setup.py build 我得到这个错误:

psutil/_psutil_linux.c:10:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1

如果有人可以帮助我安装它,那就太好了。

4

1 回答 1

27

You need to install the Python development headers too. On Debian (Raspbian “wheezy”), install the python-dev package:

sudo apt-get install python-dev

or run:

sudo apt-get build-dep python

and get a few more packages that come in handy when compiling Python C extensions. Replace python with python3 on more recent Debian releases.

On Fedora (Pidora) the equivalent of that last command is:

sudo yum install yum-utils
sudo yum-builddep python

Here too you may want to replace python with python3 if your system is more recent.

于 2013-08-14T16:45:08.600 回答