"Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel" while installing PyPy version of Numpy

The error is a bit misleading but the solution for me was to install pypy-dev (instead of python-dev).


I noted this on their site:

Installing NumPy

NumPy is an exception to the rule that most packages work without changes. The “numpy” module needs to be installed from our own repository rather than from the official source.

If you have pip (the command-line assumes that it finds the pip belonging to PyPy, not the one from CPython):

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

Alternatively, the direct way:

git clone https://bitbucket.org/pypy/numpy.git
cd numpy
pypy setup.py install

Note that NumPy support is still a work-in-progress, many things do not work and those that do may not be any faster than NumPy on CPython.

Installing More Modules


Somebody mentioned portable PyPy which I maintain. The stable builds indeed don't have numpy precompiled but I also build unstable builds from time to time which include numpy. You can see them here: https://bitbucket.org/squeaky/portable-pypy-weekly/downloads.


Here is another possibility. I found this going through their webpage. An alternate way to install (found off your link). portable binaries

When I mentioned versions, did you install python-dev or python3-dev?