6

I have a python3 script which I need to run faster, so I'm trying to install pypy3 on my raspberry pi which is running raspbian stretch 4.14.

It looks like pypy came pre-installed, but it's version 2.7.12 and it's not working with my python3 code.

I googled a lot, and can't find instructions for installing pypy3 which work for me, a lot of people suggest building from the binaries, but I'm not sure what that means either....or where to find the correct ARM architecture binary.

Please help!

AbdurRehman Khan
  • 830
  • 9
  • 20
  • 2
    https://bitbucket.org/pypy/pypy/downloads/pypy3-v6.0.0-linux-armhf-raspbian.tar.bz2 – Peter Wood Apr 16 '19 at 08:42
  • @PeterWood OMG thanks! :o Okay... sorry for being a complete noob, but I've downloaded the file on to my pi, and extracted it. It has no configure file....so how exactly am I supposed to install it now O_O the README doesn't help either and just links to pypy.org :( – AbdurRehman Khan Apr 16 '19 at 10:02
  • Nvm, I FIGURED IT OUT :') Adding an answer with all the steps I took. – AbdurRehman Khan Apr 16 '19 at 10:24

1 Answers1

9

Okay, thanks a lot to Peter Wood for linking me to the right version of pypy. Here's what I did to get it up and running on my pi (noob friendly guide :p):

Step 1: Download .tar.bz2 file using:

wget https://bitbucket.org/pypy/pypy/downloads/pypy3-v6.0.0-linux-armhf-raspbian.tar.bz2

Step 2: Extract the .tar.bz2 file:

tar xf pypy3-v6.0.0-linux-armhf-raspbian.tar.bz2

Step 3: cd into the newly extracted directory:

cd pypy3-v6.0.0-linux-armhf-raspbian.tar.bz2

Step 4: cd into the bin directory and check if the pypy3 executable works:

cd bin
./pypy3  # This should start the pypy interpreter for you

If the last command does not work, make sure pypy3 has execute permissions! (it should be green when you view it with ls). You can give it execute permissions using:

sudo chmod +x pypy3 # But you have to be in the /bin directory!

You may also get a libffi.so.5: No such file or directory error, to fix that I used:

sudo ln -s /usr/lib/arm-linux-gnueabihf/libffi.so.6 /usr/lib/arm-linux-gnueabihf/libffi.so.5

Now we want to set this up so that simply typing pypy3 from anywhere will invoke this interpreter. Here's how we can do that.

Step 5: Move the folder to /opt/

sudo mv /home/pi/pypy3-v6.0.0-linux-armhf-raspbian/ /opt/

Step 6: Add symbolic link to /usr/bin/ by running:

sudo ln -s /opt/pypy3-v6.0.0-linux-armhf-raspbian/bin/pypy3 /usr/bin/pypy3

Okay, now cd out of there and run pypy3 from any location, it should invoke the pypy interpreter! Hope this helps :)

AbdurRehman Khan
  • 830
  • 9
  • 20
  • for me this fails when running `pypy3 -m ensurepip` with `Ignoring ensurepip failure: pip 9.0.1 requires SSL/TLS`. Pip is pretty essential for a python install... – Ant6n Oct 20 '19 at 23:43
  • @Ant6n Interesting....I googled your error and came across [this](https://stackoverflow.com/questions/37723236/pip-error-while-installing-python-ignoring-ensurepip-failure-pip-8-1-1-requir) and [this](https://stackoverflow.com/questions/50126814/ignoring-ensurepip-failure-pip-requires-ssl-tls-error-in-ubuntu-18-04) You may need to install some SSL/TLS dependencies that exist with your python/pypy version. – AbdurRehman Khan Oct 21 '19 at 09:02
  • @Ant6n Try this too: https://stackoverflow.com/questions/25981703/pip-install-fails-with-connection-error-ssl-certificate-verify-failed-certi You can ignore SSL errors with --trusted-host. Finally, upgrade your pip, 9.0.1 is a really old version. That may be a cause as well. – AbdurRehman Khan Oct 21 '19 at 10:09
  • I've done a couple of searches, and tried some of those solutions. The solutions asking to install various modules (like libssl-dev) don't work on the compiled pypy, and appear to assume that one has to recompile python -- I tried compiling pypy on the raspberry pi, but it doesn't have enough memory. The `--trusted-host` argument doesn't appear to work when installing pip itself (via `get-pip.py` or `-m ensurepip`). I also couldn't find any installation instruction to install `easy_install`, which I think comes with cpyhton by default. – Ant6n Oct 21 '19 at 17:51
  • @Ant6n What about upgrading pip? Also, when you install pypy3, is pip not in there by default? I do remember having some pip issues back when I posted this question...but I don't quite remember how I solved them... it's difficult to pinpoint your problem without seeing your error upfront. If you still can't solve this, I'd be happy to help figure it out with you, you'd need to set up something like dataplicity on your raspberry pi which can grant other people access to your pi's terminal remotely. Hit me up if you're interested! – AbdurRehman Khan Oct 22 '19 at 06:29
  • pypy3 doesn't come with pip by default, that's what the 'ensurepip' module is for. In the end I went to pypi and downloaded all the required modules for my project individually, and just placed their source code in the same directory. It's a terrible hack, but it works... – Ant6n Oct 24 '19 at 05:13
  • @Ant6n Ah I see, LOL damn, very tedious. But hey, you solved the problem so congrats. – AbdurRehman Khan Oct 24 '19 at 05:26