Raspberry pi streamlit

I verified this solution and it works with LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libatomic.so.1.2.0 so it could be posted on a blog :slight_smile:

1 Like

I think i may have found a very easy workaround:

PYARROW_CMAKE_OPTIONS="-DARROW_ARMV8_ARCH=armv8-a" pip3 install streamlit

Just passing the correct flag along to the arrow cmake.

Building llvm or arrow from source (separately from pip) is not needed.

1 Like

I would love if just it where that simple. I have however not been able to install Streamlit this way on a fresh install of 2020-08-20-raspios-buster-armhf-lite (Debian 10, “Buster”) on a Raspberry Pi 4 Model B, 2 Gb RAM.
Just to eliminate that source of error I did not install any virtual Python environment.
Still, I got his error:
Traceback (most recent call last):

 File "/home/pi/.local/bin/cmake", line 6, in <module>
   from cmake import cmake

ModuleNotFoundError: No module named ‘cmake’
error: command ‘cmake’ failed with exit status 1

The fun thing, though, is that if I just go to Python (Python 3.7.3) I have no trouble importing cmake from cmake.

1 Like

I decided to upgrade to a USB SSD from my old SD card, and did a clean install of 2020-08-20-raspios-buster-arm64-lite.

I decided to give @tshoem’s workaround a try since armv8-a refers to 64 bit arm. Unfortunately, it didn’t work. The build fails with:

    -- Could NOT find Arrow (missing: Arrow_DIR)
    -- Checking for module 'arrow'
    --   No package 'arrow' found

I think the solution would have worked if it weren’t for this bug: https://issues.apache.org/jira/browse/ARROW-9791

After that bug is resolved, we can likely build pyarrow with:

  pip install pyarrow
1 Like

I found an easier way to get streamlit installed using @tshoem’s workaround and the Apach Arrow package repository! This is for 64 bit Raspberry Pi OS.

# Download the package repo keyring
$ wget https://apache.bintray.com/arrow/debian/apache-arrow-archive-keyring-latest-buster.deb

# Install it
$ sudo apt install ./apache-arrow-archive-keyring-latest-buster.deb

# Update apt
$ sudo apt update

# Install apache arrow headers
$ sudo apt install libarrow-dev
$ sudo apt install libarrow-python-dev

# Install streamlit
$ PYARROW_CMAKE_OPTIONS="-DARROW_ARMV8_ARCH=armv8-a" pip install streamlit

@shadanan I am looking forward to getting back to the UK and trying out this solution. IMO the combo of vscode & streamlit on a Pi4 makes for a very viable platform for developing and deploying kiosk type apps, and it would be fantastic to create a demo solution and contribute that the streamlit docs or example repos. Any thoughts @randyzwitch ?

We’re re-organizing the docs to make tutorials more prominent, would love to add this :+1:

1 Like

Second that (it worked for me, on a very recent update of Raspbian 32 bit)
I don’t blog but I cross-posted at:

It is a substantial build:
disk space to build: ~ 5.6 GB for llvm, ~0.6 GB for arrow
disk space of the install: ~ 0.7 GB

Because I had installed some of the Python packages previously (Cython, most specifically) as the pi user, but not with sudo, I had to re-install those packages using sudo for the last step:

sudo python setup.py install

So a huge thank you to @ shadanan, because I had been struggling to get a different python package fully installed (PyMedPhys) which had a dependency on streamlit (which had a dependency on arrow). I attributed the answer to shadanan at the streamlit forum… I hope that’s the right way to do things.

1 Like

Might it be worth reaching out over at https://github.com/imrehg/arm-wheels to see if pyarrow can have an arm wheel created using their procedure?

1 Like

@shadanan tried your approach on a Pi4 and it fails at the final step:

PYARROW_CMAKE_OPTIONS="-DARROW_ARMV8_ARCH=armv8-a" pip install streamlit
  -- Running cmake for pyarrow
  error: command 'cmake' failed with exit status 1
  ERROR: Failed building wheel for pyarrow
Failed to build pyarrow
ERROR: Could not build wheels for pyarrow which use PEP 517 and cannot be installed directly 

are there any additional steps?

@robmarkcole, these instructions worked for me on a fresh install of 64 bit Raspberry Pi OS.

Are you using 64 bit Raspberry Pi OS? This is not the default. You can check with:

$ uname -m

If you’re on 32 bit, you’ll see something like this:

$ uname -m

If you are on 32 bit, then you have to change PYARROW_CMAKE_OPTIONS="-DARROW_ARMV8_ARCH=armv8-a" to something else, but I’m not exactly sure what. I tried digging in to the Apache Arrow’s cmake files, but without much success. In any case, I won’t be able to test anything I come up with because I’m not running 32 bit. If you can figure it out, that would make everyone’s lives easier.

If you are on 64 bit and my instructions didn’t work, let me know. Maybe I forgot something. I have an extra SSD lying around and I might have time to try and repro my steps next weekend.

@shadanan my apologies I should have clarified this was on 64 bit Ubuntu on pi, Ubuntu Desktop 20.10 to be precise

@robmarkcole okay, good to know. I’ll see if I can get my instructions to work on Ubuntu next weekend.

Hey @robmarkcole,

Good news; I got pyarrow to install on 64 bit Ubuntu 20.10. It took a lot of trial and error (and the majority of the weekend), but these steps work for me on a clean install.

# Download the package repo keyring
$ wget https://apache.bintray.com/arrow/ubuntu/apache-arrow-archive-keyring-latest-focal.deb

# Install it
$ sudo apt install ./apache-arrow-archive-keyring-latest-focal.deb

# Update apt
$ sudo apt update

# Install apache arrow headers pegged at version 1.0.1-1
$ sudo apt install libarrow-dev=1.0.1-1 libarrow-python-dev=1.0.1-1
$ sudo apt-mark hold libarrow-dev libarrow-python-dev

# Install streamlit
$ ARROW_HOME=/usr PYARROW_CMAKE_OPTIONS="-DARROW_ARMV8_ARCH=armv8-a" pip install streamlit

For some reason, in Ubuntu, I needed to specify ARROW_HOME=/usr which I didn’t have to do in Raspberry Pi OS 64 Bit.

Another thing I noticed was that the latest arrow libraries are now at 2.0.0, whereas the version of pyarrow in pypi is still 1.0.1, so when installing the headers, I pinned them to match the version in pypi. This is a necessary step, as upgrading those packages to 2.0.0 will break your streamlit installation. :sob:

I really hope that apache arrow starts publishing wheels for aarch64 the same way numpy does. This will save a lot of people these headaches.

1 Like

@shadanan thanks for your effort on this. Unfortunately when I followed the instructions above I get error:

Failed to build pyarrow
ERROR: Could not build wheels for pyarrow which use PEP 517 and cannot be installed directly

This could be due to files hanging around from earlier efforts, I’m not sure. Nevertheless as it stands streamlit on Pi is not beginner friendly, and unfortunately it doesn’t look like the picture will improve any time soon

Hey Rob!

Great topic here!

I’m raspberry pi noob who wants to get started! :raised_hands:

Which device would you recommend buying?


cc: @andfanilo @okld @randyzwitch

HI @Charly_Wargnier
talking hardware the new Pi 400 looks like a great choice, not just because of the nice form factor but the also overclocked the CPU.
However as per discussion above streamlit on Pi is not beginner friendly alas

Hi, how can I solve this issue. Thanks in advance.

Pyarrow has been such a pain in the head

I have mamaged to solve the issue by running these commands using conda:

conda install pyarrow -c conda-forge
pip install streamlit
I am using Archiconda3-0.2.3-Linux-aarch64.sh
wget https://github.com/Archiconda/build-tools/releases/download/0.2.3/Archiconda3-0.2.3-Linux-aarch64.sh

Same pyarrow headaches on Jetson nano…