I encountered this error whiling install the PyPy port of Numpy on Ubuntu 16.04. Here is how to solve it.

The command line I used was:

1
$ pip install git+https://bitbucket.org/pypy/numpy.git

The error message was like this:

1
2
3
# a bunch of tracebacks
# then this line
SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.

The solution is actually to install the pypy-dev package instead of the python-dev package suggested by the error message.

1
2
$ sudo apt-get intall pypy-dev
$ pip install git+https://bitbucket.org/pypy/numpy.git

Thanks to http://askubuntu.com/a/612016/219398.