Install and run PyPy on Amazon Linux

Jan 18, 2016 AWS 中文版

In many cases, we can use PyPy to improve the performance of Python programs in an easy way. Of course, we can run PyPy on Amazon Linux (AWS EC2). This post is about two ways to install and run PyPy on Amazon Linux.



Install PyPy via yum

This is the simplest way to install PyPy on Amazon Linux because Amazon already provides PyPy 2.4 ( the newest one is PyPy 4.0.1 ) for us. Thus, we can use yum to install it. To install:

sudo yum --enablerepo=amzn-preview install pypy


Install Portable PyPy

The other way is to install Portable PyPy. All we have to do is download and unzip it. To install:

# Download Portable PyPy
wget https://bitbucket.org/squeaky/portable-pypy/downloads/pypy-4.0.1-linux_x86_64-portable.tar.bz2

# Unzip
tar -xvf pypy-4.0.1-linux_x86_64-portable.tar.bz2


Run PyPy

If you installed PyPy via yum, you can execute pypy right away. And if you want to run Portable PyPy, the executable PyPy is located in the directory: pypy-4.0.1-linux_x86_64-portable/bin. Take a look about the file structure:

pypy-4.0.1-linux_x86_64-portable
├── bin
│   ├── libpypy-c.so
│   ├── pypy
│   └── virtualenv-pypy

To execute Portable PyPy:

pypy-4.0.1-linux_x86_64-portable/bin/pypy

And it’s apparently not convenient for us to run it. So, we can create a symbolic link and put it into /usr/local/bin. To create a symbolic link:

# Create symbolic link
sudo ln -s /path/to/pypy-4.0.1-linux_x86_64-portable/bin/pypy /usr/local/bin

Remember don’t move or copy the executable PyPy outside of the directory.

Install pip for PyPy

First, we have to get get-pip.py, and then execute it to install pip. To install pip:

# Get get-pip.py
wget https://bootstrap.pypa.io/get-pip.py

# Install pip
pypy get-pip.py

To install modules:

pypy -m pip install module-name



You might also like:




If you have any suggestions, questions or even find some typos, feel free to contact me. Thank you! :)

zeckli.devforgalaxy@gmail.com   © 2015-2019 zeckli, thanks to Jekyll and GitHub.