Sam Debruyn

Cloud Data Solution Architect

Specialized in Microsoft Azure, Fabric & modern data stack. Microsoft Data Platform MVP. Public speaker & meetup organizer. FOSS contributor.

Sam Debruyn

Installing the Azure Event Hubs Python SDK on Raspberry Pi OS 64-bit

3 minutes

Since we’re going through some heat waves in Europe, I thought it might be interesting to start measuring the humidity, temperature and pressure in my apartment. To do so, I decided to use my Raspberry Pi 3 and the Pi Sense HAT running a Python script constantly sending measurements to an Azure Event Hub.

On my Raspberry Pi I’m using the beta 64-bit Raspberry Pi OS (used to be called Raspbian) so it’s a Pi-flavoured version of Debian for aarch64 (ARM64).

This all seemed fairly simple until I had to install the Azure Event Hubs Python SDK on the Pi. The command to install the SDK is

1pip3 install azure-eventhub

The SDK relies on uamqp and tries to install it as a dependency, but there are no wheels yet for aarch64 . So it tries to compile the C library while installing the dependencies. This did not seem to work on my Raspberry Pi as the compilation went out of memory.

You can start by decreasing the GPU memory allocation to 16MB (freeing up RAM for the CPU) with the raspi-config utility.

Next, you can increase the size of the swap file by editing /etc/dphys-swapfile.

 1# /etc/dphys-swapfile - user settings for dphys-swapfile package
 2# author Neil Franklin, last modification 2010.05.05
 3# copyright ETH Zuerich Physics Departement
 4#   use under either modified/non-advertising BSD or GPL license
 5
 6# this file is sourced with . so full normal sh syntax applies
 7
 8# the default settings are added as commented out CONF_*=* lines
 9
10
11# where we want the swapfile to be, this is the default
12#CONF_SWAPFILE=/var/swap
13
14# set size to absolute value, leaving empty (default) then uses computed value
15#   you most likely don't want this, unless you have an special disk situation
16CONF_SWAPSIZE=2048
17
18# set size to computed value, this times RAM size, dynamically adapts,
19#   guarantees that there is enough swap without wasting disk space on excess
20#CONF_SWAPFACTOR=2
21
22# restrict size (computed and absolute!) to maximally this limit
23#   can be set to empty for no limit, but beware of filled partitions!
24#   this is/was a (outdated?) 32bit kernel limit (in MBytes), do not overrun it
25#   but is also sensible on 64bit to prevent filling /var or even / partition
26#CONF_MAXSWAP=2048

Next, I tried compiling the uamqp dependency first before retrying to install azure-eventhub again.

To do so, run the following commands:

 1# Install the required dependencies to compile uamqp
 2sudo apt install -y build-essential libssl-dev uuid-dev cmake libcurl4-openssl-dev pkg-config python3-dev python3-pip curl
 3
 4# Clone the C library source and submodules
 5git clone --recursive https://github.com/Azure/azure-uamqp-c.git
 6
 7# Create a build directory, switch to it and set it up
 8mkdir cmake
 9cd cmake
10cmake ..
11
12# Build
13cmake --build .
14
15# Install
16sudo make install
17
18# Install the Python package without the binary
19pip3 install uamqp --no-binary :all:

If you now run pip3 install azure-eventhub again, the installation will probably succeed within a few seconds.

You might also like

If you liked this article, follow me on LinkedIn, Bluesky, or other social media to stay up-to-date with my latest posts. You might also like the following 2 posts about related topics:

Deploy a data lake on Azure in less than an hour

1 minutes

This talk was given on multiple occasions: During a lunch webinar at dataroots . At Data Science Leuven (event details ). A data lake is fundamental to a modern big data approach so it’s important to set it up the right way. But how can you do that without having to spend hours on research and then losing days configuring every component of the data lake?

Serverless on Azure @ Tech Dive September 2019

1 minutes

On September 26th, 2019, I organized the RMDY Tech Dive in Edegem. This was a public event with several topics about web, cloud & mobile app development. During this meetup, I did a talk about serverless on Azure. I explained what serverless is, what Azure Functions are and how you can use them to build your own serverless applications.