| 1 |
Downloading and Installing PyPy |
| 2 |
=============================== |
| 3 |
|
| 4 |
Just like CPython, you need a base interpreter environment and then can install |
| 5 |
extra packages. The choices for installing the base interpreter are: |
| 6 |
|
| 7 |
- Use conda (x86_64 windows, macOS, linux, arm64 linux) |
| 8 |
- Use your distribution package manager (linux) |
| 9 |
- Use homebrew (macOS) |
| 10 |
- Use the prebuilt tarballs |
| 11 |
- Build from source |
| 12 |
|
| 13 |
Using conda |
| 14 |
~~~~~~~~~~~~~~~~~~~~~ |
| 15 |
|
| 16 |
If you require compiled (c-extension) modules like SciPy, we |
| 17 |
recommend you use conda and pypy3.9, which works on Windows10, macOS, and linux |
| 18 |
x86_64. You can read more about this in the `blog post`_. |
| 19 |
|
| 20 |
.. code-block:: console |
| 21 |
|
| 22 |
$ conda create -c conda-forge -n my_cool_pypy pypy python=3.9 |
| 23 |
$ conda activate my_cool_pypy |
| 24 |
$ conda install scipy |
| 25 |
|
| 26 |
Using homebrew |
| 27 |
~~~~~~~~~~~~~~ |
| 28 |
|
| 29 |
On macOS you can also use homebrew, which provides signed packages. As of May |
| 30 |
2024, you can find pypy3.9 and pypy3.10 there. |
| 31 |
|
| 32 |
.. _`blog post`: https://www.pypy.org/posts/2022/11/pypy-and-conda-forge.html |
| 33 |
|
| 34 |
Linux distributions |
| 35 |
~~~~~~~~~~~~~~~~~~~ |
| 36 |
|
| 37 |
Some Linux distributions provide a pypy package. Note that in order to |
| 38 |
install additional modules that require compilation, you may need to install |
| 39 |
additional packages such as pypy-dev. This will manifest as an error about |
| 40 |
"missing Python.h". Distributions do not as of yet supply many pypy-ready |
| 41 |
packages, if you require additional modules we recommend creating a virtualenv |
| 42 |
and using pip. |
| 43 |
|
| 44 |
.. _prebuilt-pypy: |
| 45 |
|
| 46 |
Download a pre-built PyPy |
| 47 |
~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 48 |
|
| 49 |
The quickest way to start using PyPy is to download a prebuilt binary for your |
| 50 |
OS and architecture. You may be able to use either use the |
| 51 |
`most recent release`_ or one of our `development nightly build`_. |
| 52 |
|
| 53 |
Please note that the nightly builds are not guaranteed to be as stable as |
| 54 |
official releases, use them at your own risk. Also the macOS binaries are not |
| 55 |
signed, which means you need to convince macOS they are safe for use. |
| 56 |
|
| 57 |
.. _most recent release: https://pypy.org/download.html |
| 58 |
.. _development nightly build: https://buildbot.pypy.org/nightly/trunk/ |
| 59 |
.. _Linux binaries: https://pypy.org/download.html#linux-binaries-and-common-distributions |
| 60 |
|
| 61 |
PyPy is ready to be executed as soon as you unpack the tarball or the zip |
| 62 |
file, with no need to install it in any specific location: |
| 63 |
|
| 64 |
.. code-block:: console |
| 65 |
|
| 66 |
$ tar xf pypy-x.y.z.tar.bz2 |
| 67 |
$ ./pypy-x.y.z/bin/pypy |
| 68 |
Python 2.7.x (xxxxxxxxxxxx, Date, Time) |
| 69 |
[PyPy x.y.z with GCC x.y.z] on linux2 |
| 70 |
Type "help", "copyright", "credits" or "license" for more information. |
| 71 |
And now for something completely different: ``PyPy is an exciting technology |
| 72 |
that lets you to write fast, portable, multi-platform interpreters with less |
| 73 |
effort'' |
| 74 |
>>>> |
| 75 |
|
| 76 |
If you want to make PyPy available system-wide, you can put a symlink to the |
| 77 |
``pypy`` executable in ``/usr/local/bin``. It is important to put a symlink |
| 78 |
and not move the binary there, else PyPy would not be able to find its |
| 79 |
library. |
| 80 |
|
| 81 |
Installing more modules |
| 82 |
~~~~~~~~~~~~~~~~~~~~~~~ |
| 83 |
|
| 84 |
If you want to install 3rd party libraries, the most convenient way is |
| 85 |
to install pip_ using ensurepip_ (unless you want to install virtualenv as |
| 86 |
explained below; then you can directly use pip inside virtualenvs): |
| 87 |
|
| 88 |
.. code-block:: console |
| 89 |
|
| 90 |
$ ./pypy-xxx/bin/pypy -m ensurepip |
| 91 |
$ ./pypy-xxx/bin/pypy -mpip install -U pip wheel # to upgrade to the latest versions |
| 92 |
$ ./pypy-xxx/bin/pypy -mpip install pygments # for example |
| 93 |
|
| 94 |
Third party libraries will be installed in ``pypy-xxx/site-packages``. As with |
| 95 |
CPython, scripts on linux and macOS will be in ``pypy-xxx/bin``, and on windows |
| 96 |
they will be in ``pypy-xxx/Scripts`` |
| 97 |
|
| 98 |
|
| 99 |
Installing using virtualenv |
| 100 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 101 |
|
| 102 |
It is often convenient to run pypy inside a virtualenv. To do this |
| 103 |
you need a version of virtualenv -- 1.6.1 or greater. You can |
| 104 |
then install PyPy both from a precompiled tarball or from a git |
| 105 |
checkout after translation:: |
| 106 |
|
| 107 |
# from a tarball |
| 108 |
$ virtualenv -p /opt/pypy-xxx/bin/pypy my-pypy-env |
| 109 |
|
| 110 |
# from the git checkout |
| 111 |
$ virtualenv -p /path/to/pypy/pypy/translator/goal/pypy-c my-pypy-env |
| 112 |
|
| 113 |
# in any case activate it |
| 114 |
$ source my-pypy-env/bin/activate |
| 115 |
|
| 116 |
Note that my-pypy-env/bin/python is now a symlink to my-pypy-env/bin/pypy |
| 117 |
so you should be able to run pypy simply by typing:: |
| 118 |
|
| 119 |
$ python |
| 120 |
|
| 121 |
You should still upgrade pip and wheel to the latest versions via:: |
| 122 |
|
| 123 |
$ my-pypy-env/bin/pypy -mpip install -U pip wheel |
| 124 |
|
| 125 |
.. _pip: https://pypi.python.org/pypi/pip |
| 126 |
.. _ensurepip: https://docs.python.org/3/library/ensurepip.html |
| 127 |
|
| 128 |
Building from source |
| 129 |
~~~~~~~~~~~~~~~~~~~~ |
| 130 |
|
| 131 |
If you're interested in getting more involved, or doing something different with |
| 132 |
PyPy, consult :doc:`the build instructions <build>`. |