Python on Raspberry Pi

A lot of this is about Astropy and Astroplan because that’s what I was doing at the time. The main issue I remember is having to install the correct Raspberry Pi build of certain programs (I don’t remember which exactly now but the information is in here somewhere if I do again).

https://www.python.org/downloads

Raspberry Pi OS and Python versions support and description here.

The command pip3 is made for Python 3, so use it, not just pip.

  • Python 3.9.2 comes installed on the Raspberry Pi OS. Python 3.9.2 was released in Feb 2021.
  • Miniconda 3.5.5 installs Python 2.7.7. Python 2.7.7 was released in Jun 2014 (same month as Miniconda 3.5.5)
  • The Miniconda installation instructions specifically say you can leave Python installed do not remove it (see link below under Miniconda).
  • Astroplan uses the Python package Numpy. Use either the Linux command pip3 list, or python -c "import numpy; print(numpy.__version__)" to find the Numpy version installed.
    • I have Numpy 1.19.5. Is that because the legacy Miniconda installed it or because of the Python 3.9.2 installed on the Raspberry Pi OS? I think it’s the Python 3.9.2 from the OS.
    • Numpy downloads for Raspberry Pi here.
    • On my first test with Astroplan (and Astropy) I had a Numpy error that sent me to this link. The correction was sudo apt-get install libatlas-base-dev. I also updated Numpy with pip3 install numpy --upgrade and it upgraded to Numpy 1.21.5

Astropy on a Raspberry Pi Zero W

This is step-by-step how to install Astropy and Astroplan on a Raspberry Pi Zero W (1st gen, not the ‘2’).

Raspberry Pi OS download here along with imager here.

sudo passwd (change from default as desired for security)

sudo raspi-config

Set up location, time zone, language, keyboard, Wi-Fi, SSH. Turn off Bluetooth? How?

python --version

>> Python 3.9.2

sudo apt install python3-pip – for the Raspberry Pi, it is better to not use pip because it installs software not compiled for the Pi (the Pi Zero ISA is ARMv6l).

sudo apt install python3-numpy

sudo apt install python3-astropy

Note! Astropy installs this one. Not the rc2 or any of the other ones.

sudo apt install python3-pyerfa (installs with Astropy – I think)

sudo apt install python3-pyyaml (installs with Astropy – I think)

sudo apt install python3-packaging (installs with Astropy – I think)

sudo apt install python3-astroplan

sudo apt install python3-pytz (installs with Astroplan)

Other Astroplan options here.

sudo apt install python3-astroquery

sudo apt install python3-scipy

sudo apt install python3-kivy

sudo apt install fim

sudo apt install kivy

sudo apt install libmtdev1

sudo apt autoremove

Hardware

The Raspberry Pi Zero W is 32-bit and uses ARMv6 instead of the newer ARMv7. The [biggest? only?] difference is in how the processor handles floating point operations.

The Raspberry Pi Zero 2 W is 64-bit.

The Raspberry Pi OS version 11 – the latest version still – is 32-bit. A 64-bit Raspberry Pi OS is in development but not available yet.

To check the version of Raspberry Pi OS installed, cat /etc/os-release.

Python

Python comes already installed with the Raspberry Pi OS. To verify, type python --version. You could install if necessary with sudo apt install python3.8x.

sudo apt update is also a good command to run.