Raspberry pi streamlit

I am working on a couple of streamlit apps which will eventually be deployed in docker containers on a raspberry pi, and thought I would start this thread incase anyone else is using a pi for deployment.

Installation

On an RPi 4 with raspbian Buster.
It was necessary to first:

$ sudo apt-get install libatlas-base-dev

but I was then able to run streamlit on rpi with no problems, viewing the app using the built in Chromium browser.

Apps

My primary use case is an app to facilitate the optimisation of parameters in a computer vision system that is integrated to my home automation platform. However I think streamlit on an rpi could also have many applications in education, museums/galleries, and in small businesses.

7 Likes

I know of a couple of users who have told me they are using pi. I’ll ping them to see if they have any thoughts for you!

2 Likes

Got a POC working, it is the streamlit demo running in a docker container on an RPi4. I’ve actually installed it as a Home Assistant addon, which provides a nice UI for managing docker images on the pi. This opens up the possibility of creating streamlit data science apps for Home Assistant, or just using Home Assistant as a user friendly way for non technical people to deploy the streamlit apps. I think I will create an app for doing prediction of time series sensor data using the prophet library.

Screenshot from my ipad below:

5 Likes

Hello,
I am having issues installing streamlit in a virtualenv on RPi 3 B+ using python 3.7.3. Problem installing dependency pyarrow. The following is the error.

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

How to resolve this issue?

In my experience use of virtualenv on pi can cause issues, try installing system wide then progress from there

Thanks a lot for your quick reply. But I faced the same problem while installing it on a system level.

Installing streamlit==0.62.0 temporarily solved my problem.

Appears pyarrow dependency is not pinned, so it is a bit surprising that installing an earlier version of streamlit solved this issue. Any ideas @randyzwitch ?

A downgrade “works”, because pyarrow is part of 0.63 and Components. The point is just to be able to pass dataframes to the front-end, I don’t know that we necessarily need a specific version.

Seeing the PEP517 message though and Googling brought me to:

Is Raspberry Pi a 32-bit system? It sounds like Arrow has an issue here with 32-bit and pip.

There are both 32 bit and 64 bit in circulation, but 32 bit is far more common. I just tried to install streamlit on a 32bit pi4 and it failed. @nightmareforev you can check your OS version following this instruction.

Yeah, mine is 32 bit too.
I running Raspbian buster on armv7l.

Hello,

First time posting to the streamlit discussions. I’ve also been trying to install streamlit on a raspi4b and running into an issue compiling pyarrow. I’m on a 64bit ubuntu with an armv8/aarch64 cpu. It looks like the architecture flag for gcc -march=armv8-a is being rejected by the compiler for some reason. I don’t know enough to go any further in debugging this issue. I hope this helps!

I would also like to get streamlit running on my pi.

2 Likes

I’m hitting the same problem!
I tried several versions of pyarrow (0.9.0, 0.10.0, 0.17.1, 1.0.0) but I wasn’t able to install any of them unfortunately.

Is there a workaround other than downgrading streamlit?

Maybe try using miniconda as your build environment? If you can do conda install pyarrow and get a successful install, you can run pip install streamlit after and hopefully get a better result.

Otherwise, not sure what a temporary fix might be. Downgrading works for the short-term, but we are looking to move more of our functionality to Arrow, so we should find a more reasonable solution

1 Like

Unfortunately it does not work

pyarrow is on conda-forge

conda install -c conda-forge pyarrow

1 Like

Just ran in to this bug while trying to install streamlit to my Raspberry Pi 4. Basically, I can’t seem to get pyarrow installed. Installing streamlit==0.62.0 works as a workaround for now.

This is a problem with pyarrow on arm7l, not with streamlit, but here’s the relevant error messages from the log, which will help people that are googling.

  -- Could NOT find Arrow (missing: Arrow_DIR)
  -- Checking for module 'arrow'
  --   No package 'arrow' found
  CMake Error at /usr/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
    Could NOT find Arrow (missing: ARROW_INCLUDE_DIR ARROW_LIB_DIR
    ARROW_FULL_SO_VERSION ARROW_SO_VERSION)
  Call Stack (most recent call first):
    /usr/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
    cmake_modules/FindArrow.cmake:412 (find_package_handle_standard_args)
    cmake_modules/FindArrowPython.cmake:46 (find_package)
    CMakeLists.txt:210 (find_package)


  -- Configuring incomplete, errors occurred!
  See also "/tmp/pip-install-d22ajzwt/pyarrow/build/temp.linux-armv7l-3.7/CMakeFiles/CMakeOutput.log".
  error: command 'cmake' failed with exit status 1

  ----------------------------------------
  Failed building wheel for pyarrow

I tried using conda from @randyzwitch latest comment, but it doesn’t work:

$ conda install -c conda-forge pyarrow
Fetching package metadata: ........
Error: No packages found in current linux-armv7l channels matching: pyarrow

Did you mean one of these?

    arrow, pyrr

You can search for this package on anaconda.org with

    anaconda search -t conda pyarrow

You may need to install the anaconda-client command line client with

    conda install anaconda-client 

While googling around, I stumbled across https://issues.apache.org/jira/browse/ARROW-9791 which might be relevant.

Hey @shadanan, welcome to the Streamlit community! Thanks for doing the research, hopefully the Arrow community can start supporting this some time in the future :crossed_fingers:

I finally got streamlit working on my Raspberry Pi 4. Unfortunately, this turned out to be a lot of work. I will provide as much guidance as possible, but I’m un-inclined to try and do a full tutorial write-up because I don’t want to accidentally break my install.

Here are the steps I used:

  1. Prepare your LD_LIBRARY_PATH. You’ll want to put this in .bashrc or .zshrc.

    $ export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
    
  2. Install llvm-10 from source – unfortunately, arrow requires llvm-10 at a minimum and the latest llvm in the raspbian package repos was llvm-9. If you can get llvm-10 in some other way, do it that way instead of this. It took a whole night to build llvm-10 on my poor Raspberry Pi.

    $ git clone https://github.com/llvm/llvm-project.git
    $ cd llvm-project
    $ git fetch --tags
    $ git checkout llvmorg-10.0.1
    $ mkdir build
    $ cd build
    $ cmake -G "Unix Makefiles" \
        -DLLVM_ENABLE_PROJECTS="clang;libcxx;libcxxabi" \
        -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=On \
        ../llvm
    $ make -j4
    $ sudo make install
    
  3. Install Apache Arrow from source. I adapted instructions from here: https://gist.github.com/heavyinfo/04e1326bb9bed9cecb19c2d603c8d521

    $ wget https://github.com/apache/arrow/archive/apache-arrow-1.0.1.tar.gz
    $ tar xzf apache-arrow-1.0.1.tar.gz
    $ cd arrow-apache-arrow-1.0.1/cpp
    $ mkdir build
    $ cd build
    $ export ARROW_HOME=/usr/local
    $ cmake \
        -DCMAKE_INSTALL_PREFIX=$ARROW_HOME \
        -DCMAKE_INSTALL_LIBDIR=lib \
        -DARROW_WITH_BZ2=ON \
        -DARROW_WITH_ZLIB=ON \
        -DARROW_WITH_ZSTD=ON \
        -DARROW_WITH_LZ4=ON \
        -DARROW_WITH_SNAPPY=ON \
        -DARROW_PARQUET=ON \
        -DARROW_PYTHON=ON \
        -DARROW_BUILD_TESTS=OFF \
        ..
    $ make -j4
    $ sudo make install
    $ cd ../../python
    $ python3 setup.py build_ext --build-type=release --with-parquet
    $ sudo python3 setup.py install
    
  4. Install streamlit.

    $ sudo pip3 install streamlit
    
  5. Run streamlit as follows. You can also put the LD_PRELOAD in your .bashrc or .zshrc. I think there’s a way to avoid having this, but it looked like I’d have to rebuild either llvm-10 or arrow, and I didn’t want to spend any more time on this.

    $ LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libatomic.so.1.2.0 streamlit run <python_script.py>
    

If someone else goes through this and can simplify these steps, I’m sure the community would appreciate it.

1 Like

@shadanan good effort finding a solution. @randyzwitch this could be wrapped up as an official docker image, created on each release of streamlit?

It’s not a bad idea to have this available @robmarkcole, but also not sure 1) it needs to be for each release and 2) it needs to be maintained by Streamlit.

From my brief reading above, it looks like it’s instructions about how to compile Arrow, which will be relatively separate from different Streamlit versions. So maybe someone could write a blog post and make a Dockerfile, and then it will exist for the community to maintain?