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.9.0 — (what's new in PyPy2.7?)
  • the Python3.5 compatible beta quality release — PyPy3.5 v5.9.0 — (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.9

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. This version is not supported and not actively maintained. You will likely have to fix some issues yourself, or checkout an old version, or otherwise play around on your own. We provide this documentation only for historical reasons. Please do not use in production. For reference, there are some very old, unmaintained binaries for Linux (32bit, 64bit).

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.9.0/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.8.0 sha256:

a0b125a5781f7e5ddfc3baca46503b14f4ee6a0e234e8d72bfcf3afdf4120bef  pypy2-v5.8.0-linux32.tar.bz2
6274292d0e954a2609b15978cde6efa30942ba20aa5d2acbbf1c70c0a54e9b1e  pypy2-v5.8.0-linux64.tar.bz2
28b7fd0cc7418ffc66c71520728e87941be40ebf4b82675c57e25598a2a702b0  pypy2-v5.8.0-linux-armel.tar.bz2
ddceca9c5c9a456d4bf1beab177660adffbbdf255a922244e1cc05f20318be46  pypy2-v5.8.0-linux-armhf-raring.tar.bz2
da58279a0e3706889fc0df06087cea08f8cfd22322139fe9bae73ef9b2d119b7  pypy2-v5.8.0-linux-armhf-raspbian.tar.bz2
04b61d1cf13aaca6d0420e854c820b8bd049dc88be16c02542abe8ca26eb075c  pypy2-v5.8.0-osx64.tar.bz2
35aea25e2b9d2f7c8742c47e4e7474ef0f93ce1b5e3d4f5a99795bab23c1ad2c  pypy2-v5.8.0-s390x.tar.bz2
504c2d522595baf8775ae1045a217a2b120732537861d31b889d47c340b58bd5  pypy2-v5.8.0-src.tar.bz2
ec1e34cc81a7f4086135bab29dcbe61d19fcd8d9d8fc1b149bea8373f94fd958  pypy2-v5.8.0-src.zip
43d6217653e5bdc09e3ff8cb56fb52c4eb019429063d80107be4e88eef79ea8d  pypy2-v5.8.0-win32.zip
2e464bcbc8216e55bb2433ace712130244fd1f3fa78de0c0c98745fd8ff12b03  pypy2-v5.8.0-ppc64.tar.bz2
5746823904df74423376e0326046e1171df9693a6d4c95e8ce14ca83534bae72  pypy2-v5.8.0-ppc64le.tar.bz2

pypy2.7-5.9.0 sha256:

a2431a9e4ef879da1a2b56b111013b4a6efb87d4173a37bf650de47834ac5fe4 pypy2-v5.9.0-linux32.tar.bz2 790febd4f09e22d6e2f81154efc7dc4b2feec72712aaf4f82aa91b550abb4b48 pypy2-v5.9.0-linux64.tar.bz2 ac0676d91dfb388c799ec5c2845f42018a666423376f52f3ae13d61fd2e6f87d pypy2-v5.9.0-linux-armel.tar.bz2 2597b7b21acdef4f2b81074a594157c9450363c74a17f005548c6b102f93cff4 pypy2-v5.9.0-linux-armhf-raring.tar.bz2 b8a20042a3f34486a372ff7c751539b2e16859c0a7ea69d5a73af92f0fdcb25a pypy2-v5.9.0-linux-armhf-raspbian.tar.bz2 94de50ed80c7f6392ed356c03fd54cdc84858df43ad21e9e971d1b6da0f6b867 pypy2-v5.9.0-osx64.tar.bz2 36d6b5158801c8aa4ef5b9d8990ca0a3782a38a04916be5644a33c2a82465101 pypy2-v5.9.0-s390x.tar.bz2 de4bf05df47f1349dbac97233d9277bbaf1ef3331663ea2557fd5da3dbcfd0a7 pypy2-v5.9.0-src.tar.bz2 db42dbed029eeac2da1dfe9bc71d63c934106acbed6bfad8910d2dabb557d9c2 pypy2-v5.9.0-src.zip b61081e24e05b83d8110da1262be19f0094532c6cacc293e318a1c186d926533 pypy2-v5.9.0-win32.zip

pypy 3.5-v5.8.0 sha256:

9d090127335c3c0fd2b14c8835bf91752e62756e55ea06aad3353f24a6854223  pypy3-v5.8.0-src.tar.bz2
57d871a7f1135719c138cee4e3533c3275d682a76a40ff668e95150c65923035  pypy3-v5.8.0-linux64.tar.bz2
8c868b5c8d15ce8acdf967f3c25da44bf52f6c7aa1fd1e50ebd50590f98066a4  pypy3-v5.8.0-src.zip

pypy 3.5-v5.9.0 sha256:

d8c41ede3758127718944cc2fd6bf78ed4303d946f85596cac91281ccce36165  pypy3-v5.9.0-linux64.tar.bz2
a014f47f50a1480f871a0b82705f904b38c93c4ca069850eb37653fedafb1b97  pypy3-v5.9.0-src.tar.bz2
c5d7fa206cdf425de3950ef8ff578deb0745a723b69b64bb121210a5b8df8c65  pypy3-v5.9.0-src.zip