Skip to content

Configuration

mstemmer edited this page Jan 3, 2021 · 11 revisions

All these configurations are optional, but I found them quite useful.

Default python version

By default the RaspberryPi runs on python2.

Check which python versions you have installed by
either running python and python3 in your command line.

Hatchling is written in python3 (3.7 and above) so every command should be python3 instead of python.
Note: You need at least python3.7 on your raspberry. If you have an older version you might want to consider reinstalling your OS.

Since I mainly work with python3, I changed the default python to python3.
Here is a good instruction on how to do this on Linux machines

Now whenever you type python, python3 is executed from /usr/lib/python3/
The same is then also true for related tools like pip/pip3, since it is located in the same library.

Setup Hardware Pins

The pins of the RaspberryPie are set to input by default.

To find out your pin configuration run this command in the terminal:

gpio readall

In order to avoid annoying hardware issues at system boot, set your used pins to output and adjust their default status.
I set all my used pins to putput (op) and pulled them low (dl). Only the latch pin of the LED/Buzzer driver I pulled high (dh).

You can adjust these as you wish, depending on your setup.
Note: The pin numbering here is in BCM format.

To change the configuration, go to /boot/config.txt and add these lines:
gpio=17,22,5,6,13,19,26,18,23,24,25,12,16,20,21=op,dl
gpio=27=op,dh

Create and run a python environment

Create environment

python -m venv py_env/hatchling

Enter environment

source py_env/hatchling/bin/activate

Install packages into this environment

pip install <package name>

Install all packages needed to run hatchling

pip install -r requirements.txt

Leave environment

deactivate

See als this page for more details.