Smart Cities - Tiny House at Home

From Sensors in Schools
Revision as of 22:12, 16 November 2024 by EdmondLascaris (talk | contribs)
Jump to navigation Jump to search

Raspberry Pi OS

  • Starting with a fresh install of the Raspberry Pi Debian Bookworm OS with desktop (64 bit).
  • Use the Raspberry Pi Imager to install the OS on a 16MB micro SD card.
  • Complete the set up and updates on the Raspberry Pi.

Install the real Python IDE (not thonny) and the MQTT broker

  • Open the Terminal and enter these commands
sudo apt update
sudo apt -y full-upgrade 
sudo apt install -y idle3 arduino

Install Virtual Environment

  • These days Python must run in a virtual environment so that each user gets their own Python
  • The virtual environment has to be activated before each use
  • The linux prompt then changes from:
  • <username>@home:~ $ to (env) <username>@home:~ $
  • Create a virtual environment for Python called env in your /home/<username> directory.
    • In Linux (and other operating systems), a virtual environment is an isolated Python environment that allows you to install and manage Python packages separately from the system-wide Python installation.
    • This ensures that your Python projects have their own dependencies and versions of libraries without affecting or being affected by other projects or the global Python environment.
  • Enter the commands in the Terminal.
cd ~
python3 -m venv env


  • Activate the virtual environment with the commands.
cd ~/env
source bin/activate
  • Dectivate the virtual environment with the command.
deactivate

Configure the Python Idle3 shortcut to auto-activate the Python virtual environment

  • Click Raspberry | Programming
  • Right Click IDLE (using Python-3.11)
  • Click Properties | Desktop Entry
  • In the Command: field enter
/home/<username>/env/bin/python3.11 -m idlelib.idle