Download and install

There are nightly binary builds available. Those builds are not always as stable as the release, but they contain numerous bugfixes and performance improvements.

We provide binaries for x86, ARM, PPC and s390x running on different operating systems such as Linux, Mac OS/X and Windows:

  • the Python2.7 compatible release — PyPy2.7 v5.7.1 — (what's new in PyPy2.7?)
  • the Python3.5 compatible beta quality release — PyPy3.5 v5.7.1 — (what's new in PyPy3.5?).
  • the Python2.7 Software Transactional Memory special release — PyPy-STM 2.5.1 (Linux x86-64 only)

“JIT Compiler” version

These binaries include a Just-in-Time compiler. They only work on x86 CPUs that have the SSE2 instruction set (most of them do, nowadays), or on x86-64 CPUs. They also contain stackless extensions, like greenlets.

Linux binaries and common distributions

Linux binaries are dynamically linked, as is usual, and thus might not be usable due to the sad story of linux binary compatibility. This means that Linux binaries are only usable on the distributions written next to them unless you're ready to hack your system by adding symlinks to the libraries it tries to open. There are better solutions:

Python 3.5.3 compatible PyPy3.5 v5.7

Warning: PyPy3.5 is considered beta software. All binaries are thus called “beta”. It is known to be rarely much slower than PyPy 2. You are welcome to use it anyway; if you're lucky it will be fast in your case.

If your CPU is really, really old, it may be a x86-32 without SSE2. There is untested support for manually translating PyPy's JIT without SSE2 (--jit-backend=x86-without-sse2) but note that your machine is probably low-spec enough that running CPython on it is a better idea in the first place.

[1]: stating it again: the Linux binaries are provided for the distributions listed here. If your distribution is not exactly this one, it won't work, you will probably see: pypy: error while loading shared libraries: …. Unless you want to hack a lot, try out the portable Linux binaries.

PyPy-STM 2.5.1

This is a special version of PyPy! See the Software Transactional Memory (STM) documentation.

Other versions

The other versions of PyPy are:

  • The most up-to-date nightly binary builds with a JIT, if the official release is too old for what you want to do. There are versions for different libc on this site too.
  • Reverse debugger: This version enables debugging your Python programs by going forward and backward in time. See the RevDB documentation.
  • Sandboxing: A special safe version. Read the docs about sandboxing. (It is also possible to translate a version that includes both sandboxing and the JIT compiler, although as the JIT is relatively complicated, this reduces a bit the level of confidence we can put in the result.) Note that the sandboxed binary needs a full pypy checkout to work. Consult the sandbox docs for details. (These are old, PyPy 1.8.)

Installing

All binary versions are packaged in a tar.bz2 or zip file. When uncompressed, they run in-place. For now you can uncompress them either somewhere in your home directory or, say, in /opt, and if you want, put a symlink from somewhere like /usr/local/bin/pypy to /path/to/pypy2-5.7.1/bin/pypy. Do not move or copy the executable pypy outside the tree – put a symlink to it, otherwise it will not find its libraries.

Installing more modules

There are as yet few distribution-ready packages. We recommend installing pip, which is the standard package manager of Python. It works like it does on CPython as explained in the installation documentation.

If you use your distribution's PyPy package we recommend you install packages into a virtualenv. If you try to build a module and the build process complains about “missing Python.h”, you may need to install the pypy-dev package.

Installing NumPy

There are two different versions of NumPy for PyPy.

1. NumPy via cpyext

The generally recommended way is to install the original NumPy via the CPython C API compatibility layer, cpyext. Modern versions of PyPy support enough of the C API to make this a reasonable choice in many cases. Performance-wise, the speed is mostly the same as CPython's NumPy (it is the same code); the exception is that interactions between the Python side and NumPy objects are mediated through the slower cpyext layer (which hurts a few benchmarks that do a lot of element-by-element array accesses, for example).

Installation works on any recent PyPy (the release above is fine, a recent nightly will implement more of the new buffer protocol). The currently released numpy 1.12 works except for nditers with the updateifcopy flag. For example, without using a virtualenv:

$ ./pypy-xxx/bin/pypy -m ensurepip
$ ./pypy-xxx/bin/pypy -mpip install -U wheel # to update wheel
$ ./pypy-xxx/bin/pip install cython numpy

(See the general installation documentation for more.)

2. NumPyPy

The “numpy” module can be installed from our own repository rather than from the official source. This version uses internally our built-in _numpypy module. This module is slightly incomplete. Also, its performance is hard to predict exactly. For regular NumPy source code that handles large arrays, it is likely to be slower than the native NumPy with cpyext. It is faster on the kind of code that contains many Python loops doing things on an element-by-element basis.

Installation (see the installation documentation for installing pip):

pypy -m 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

If you installed to a system directory, you need to also run this once:

sudo pypy -c 'import numpy'

Note again that this version is still a work-in-progress: many things do not work and those that do may not be any faster than NumPy on CPython. For further instructions see the pypy/numpy repository.

Building from source

(see more build instructions)

  1. Get the source code. The preferred way is to checkout the current trunk using Mercurial. The trunk usually works and is of course more up-to-date. The following command should run in about 7 minutes nowadays if you have hg >= 3.7 (it is much slower with older versions):

    hg clone https://bitbucket.org/pypy/pypy
    

    Alternatively, the following smaller package contains the source at the same revision as the above binaries:

  2. Make sure you installed the dependencies. See the list here.

  3. Enter the goal directory:

    cd pypy/pypy/goal
    
  4. Run the rpython script. Here are the common combinations of options (works also with python instead of pypy; requires CPython 2.7 or PyPy 2):

    pypy ../../rpython/bin/rpython -Ojit targetpypystandalone           # get the JIT version
    pypy ../../rpython/bin/rpython -O2 targetpypystandalone             # get the no-jit version
    pypy ../../rpython/bin/rpython -O2 --sandbox targetpypystandalone   # get the sandbox version
    
  5. Enjoy Mandelbrot :-) It takes on the order of half an hour to finish the translation, and about 3GB of RAM on a 32-bit system and about 5GB on 64-bit systems. (Do not start a translation on a machine with insufficient RAM! It will just swap forever. See notes below in that case.)

  6. If you want to install this PyPy as root, please read the next section, Packaging.

Notes:

  • It is recommended to use PyPy to do translations, instead of using CPython, because it is twice as fast. You should just start by downloading an official release of PyPy (with the JIT). If you really have to use CPython then note that we are talking about CPython 2.7 here, not CPython 3.x. (Older versions like 2.6 are out.)

  • On some 32-bit systems, the address space limit of 2 or 3 GB of RAM can be an issue. More generally you may be just a little bit low of RAM. First note that 2 GB is really not enough nowadays; on Windows you first need to refer to the Windows build instructions. More precisely, translation on 32-bit takes at this point 2.7 GB if PyPy is used and 2.9 GB if CPython is used. There are two workarounds:

    1. use PyPy, not CPython. If you don't have any PyPy so far, not even an older version, then you need to build one first, with some parts removed. So, first translate with ...rpython -Ojit targetpypystandalone --withoutmod-micronumpy --withoutmod-cpyext, then copy pypy-c and libpypy_c.so somewhere else, and finally call it with ...pypy-c ../../rpython/bin/rpython -Ojit.

    2. if even using PyPy instead of CPython is not enough, try to tweak some internal parameters. Example (slower but saves around 400MB):

    PYPY_DONT_RUN_SUBPROCESS=1 PYPY_GC_MAX_DELTA=200MB pypy --jit loop_longevity=300 ../../rpython/bin/rpython -Ojit --source
    # then read the next point about --source
    
  • You can run translations with --source, which only builds the C source files (and prints at the end where). Then you can cd there and execute make. This is another way to reduce memory usage. Note that afterwards, you have to run manually pypy-c .../pypy/tool/build_cffi_imports.py if you want to be able to import the cffi-based modules.

  • On Linux, translating with asmgcroot, is delicate. It requires using gcc with no particularly fancy options. It does not work e.g. with clang, or if you pass uncommon options with the CFLAGS environment variable. If you insist on passing these options or using clang, then you can compile PyPy with the default shadow stack option instead (for a small performance price in non-JITted code).

  • Like other JITs, PyPy doesn't work out of the box on some Linux distributions that trade full POSIX compliance for extra security features. E.g. with PAX, you have to run PyPy with paxctl -cm. This also applies to translation (unless you use CPython to run the translation and you specify --source).

Packaging

Once PyPy is translated from source the binary package similar to those provided in the section Default (with a JIT Compiler) above could be easily created with package.py script as following:

cd ./pypy/pypy/tool/release/
python package.py --help #for information
python package.py --archive-name pypy-my-own-package-name

It is recommended to use package.py because custom scripts will invariably become out-of-date. If you want to write custom scripts anyway, note an easy-to-miss point: some modules are written with CFFI, and require some compilation. If you install PyPy as root without pre-compiling them, normal users will get errors:

  • PyPy 2.5.1 or earlier: normal users would see permission errors. Installers need to run pypy -c “import gdbm” and other similar commands at install time; the exact list is in package.py. Users seeing a broken installation of PyPy can fix it after-the-fact if they have sudo rights, by running once e.g. sudo pypy -c "import gdbm.
  • PyPy 2.6 and later: anyone would get ImportError: no module named _gdbm_cffi. Installers need to run pypy _gdbm_build.py in the lib_pypy directory during the installation process (plus others; see the exact list in package.py). Users seeing a broken installation of PyPy can fix it after-the-fact, by running pypy /path/to/lib_pypy/_gdbm_build.py. This command produces a file called _gdbm_cffi.pypy-41.so locally, which is a C extension module for PyPy. You can move it at any place where modules are normally found: e.g. in your project's main directory, or in a directory that you add to the env var PYTHONPATH.

Checksums

Here are the checksums for each of the downloads

pypy2.7-v5.7.1 sha256:

f125a227f8c814ba1698168a639ea6ca59bb69c280529639eed29076d8429a73  pypy2-v5.7.1-linux32.tar.bz2
c4fa3da42156bed4a9d912433b618a141e0c5161d7cc8c328786736ea5d1c2da  pypy2-v5.7.1-linux64.tar.bz2
591a4a73cc945a1125848f3615a28559692db8febf677d7087eaef40cb119a8d  pypy2-v5.7.1-linux-armel.tar.bz2
c1b1a0968b22c58672f7492dc7900bc85e3bd02c791f219f31401a00ef387207  pypy2-v5.7.1-linux-armhf-raring.tar.bz2
67544f8c4b284db71cf1af74edef290722f97f82476cbdaff2015fdab244c6ee  pypy2-v5.7.1-linux-armhf-raspbian.tar.bz2
4e99ba356432861534917a9477ace0ccee617bd631512759a530f8383e153a3d  pypy2-v5.7.1-osx64.tar.bz2
395c57a1aa078c9ae9aa9f18263bb91fa23114bae4d133d10560eaea30c51892  pypy2-v5.7.1-s390x.tar.bz2
d01bee43c6df79f7bbc1149bb3e85f489491fb2358a6a1f9a7f0d6e07715832f  pypy2-v5.7.1-src.tar.bz2
f580a7b41cc09e030bbff66752044bdfbc193ec617e575c64bf65c136c298076  pypy2-v5.7.1-src.zip
a3ba7c946635236836f8536d8767a0f456b3b9a86876cb5c3173a04522bf451b  pypy2-v5.7.1-win32.zip
a4edb857c1f001bab4b545f2f87f3653e8cd882a95233d60d584edb9700722e9  pypy2-v5.7.1-ppc64.tar.bz2
5db9bb6429d9cf146f74360ec30b40bd0df78116f458cf14035a0b7daefa35eb  pypy2-v5.7.1-ppc64le.tar.bz2

pypy 3.5-v5.7.1 sha256:

2abaa54d88c9b70b64c37083e7e430a1d3a8f78f8de92e484a988b7aca1e50a7  pypy3-v5.7.1-linux64.tar.bz2
40ece0145282980ac121390f13709404c0532896507d5767496381180b631bd0  pypy3-v5.7.1-src.tar.bz2
97fb0075ab2ecfb912fab996c71c6a8475ff18766db6c9e060f9384b809500bd  pypy3-v5.7.1-src.zip