Skip to main content
Home
The Baheyeldin Dynasty
The journey for wisdom starts with knowledge
  • Home
  • About
  • Site Map
  • Contact

How To Upgrade HomeAssistant Core In A Python Venv Using uv

  1. Home

By Khalid on 2025/03/04 - 13:54, last updated 2025/03/04 - 16:02

Home Assistant is an open source home automation platform, written in Python, which I have been running it for several years for various tasks.

I am running it using a less common method (called Home Assistant Core), which will soon not be recommended nor supported for end users. However, I have consciously decided to run it that way, rather than use a docker container, Home Assistant OS, or the other recommended versions.

These reasons for this decision include:

  • Running custom shell scripts that are called by Home Assistant for notifications and such,
  • Running other programs on the Raspberry Pi (e.g. RTL-SDR for weather station, MariaDB, InfluxDB and Grafana for a weather panel, ...),
  • Having access to Ubuntu's vast repository of applications easily installable using apt,
  • Retaining sysadmin control over the Raspberry Pi.
  • Running ARM 64-bit Ubuntu's Long Term Release (LTS) versions on a Raspberry Pi 4, so as to upgrade less frequently, so less disruptions, and less maintenance.
  • Running Home Assistant as a regular users, in my home directory, so there is no need to sudo (except for running systemd units).

For a few years now, I was running Home Assistant in a Python Virtual Environment (venv), as I explained in a previous post, and it was working quite well.

However, because the Home Assistant development team frequently updates to newer Python versions, and Ubuntu LTS does not have these newer versions, upgrades to Home Assistant stops working after some time.

Enter uv

Thanks to Carsten Fuchs in this post, it turns out that a company called Astral released an extremely fast tool called uv which revolutionizes how specific Python versions can be deployed in different venv instances on the same machine, isolating them from the rest of the system.

This tool will become the future method to deploy Home Assistant Core.

In the rest of this page, I detail the steps you need to install Home Assistant using uv:

Prepare For The Upgrade

HA_DIR="$HOME/ha/homeassistant"
CONF_DIR="$HOME_DIR/ha/conf"

Install uv

First you need to install the uv tool itself.
This is done using downloading a shell script and running it (scary, but ...)

cd ~
curl -LsSf https://astral.sh/uv/install.sh | sh
source $HOME/.local/bin/env

Install The New Python Version

Check what the latest version of Home Assistant needs for Python, then install that:

uv python install 3.13
# Verify that it is installed
uv python list

Stop Home Assistant

Assuming that you have been using a systemd unit for Home Assistant, shut down HA

sudo systemctrl stop homeassistant

Rename The Existing HA Directory

cd $HA_DIR
cd ..

mv homeassistant homeassistant-old

Create A New Venv Directory

mkdir homeassistant

Create The Venv

Now, create the new venv, with the specific Python version needed.

uv venv . --python 3.13
source ./bin/activate

Find The Latest Version of HA

# Visit here: https://github.com/home-assistant/core/releases
uv pip install homeassistant==2025.2.5

Install A Few Required Additional Components

Newer versions of Home Assistant use TurboJpeg, so we install that:

sudo apt install libturbojpeg

Instead of the default SQLite database, I use MariaDB for the recorder integration, and my connection string starts with mysql+pymysql:// ..., I need to install the following too:

uv pip install pymysql

Run A Syntax Check On HA's Config

Before starting Home Assistant, we want to check the syntax of our configuration YAML files, in case something has changed.

$HA_DIR/bin/hass -c $CONF_DIR --script check_config

If you see errors, you need to check the documentation and fix them.

Run HA Manually, And Check Its Logs

Because this is the initial run, you need to run HA manually.

$HA_DIR/bin/hass -c $CONF_DIR 

You will on the screen what Home Assistant is doing.

Because the recorder database changes regularly, Home Assistant has to do schema modification. This update does take some time to finish, depending on the size of your database.

So please be patient.

Start Home Assistant

sudo systemctrl stop homeassistant

In another terminal, run:

tail -f $CONF/home-assistant.log

Make sure there are no errors.

Contents: 
Linux
Software
Tags: 
Home Assistant
Python
  • Add comment

Current

Pandemic

  • COVID-19
  • Coronavirus

Search

Site map

Contents

  • Family
    • Khalid
    • Ancestry
    • Extended
  • Friends
  • Nokat نكت
  • Writings
    • Cooking
    • Culture
    • Science
    • History
    • Linguistics
    • Media
    • Literature
    • Politics
    • Humor
    • Terrorism
    • Business
    • Philosophy
    • Religion
    • Children
  • Technology
    • Linux
    • Arabization
    • Drupal
      • Association
    • Software
    • Internet
    • Technology in Society
    • Digital Archeology
    • NCR History
    • MidEast Internet
    • Programming
    • Saudi ISPs
    • Miscellaneous
  • Places
    • Canada
      • Weather
    • Egypt
      • Cuisine
      • Alexandria
      • E.G.C.
    • USA
    • Saudi Arabia
  • Interests
    • Astronomy
    • Fishing
    • Photography
    • Snorkeling
    • Nature
    • Photomicroscopy
  • Miscellany

In Depth

  • al-Hakim bi Amr Allah: Fatimid Caliph of Egypt الحاكم بأمر الله
  • Alexandria, Egypt
  • Arabic on the Internet
  • Articles on the history of Muslims and Arabs in the Iberian Peninsula تاريخ المسلمين و العرب في الأند
  • DIY GOTO Telescope Controller With Autoguiding and Periodic Error Correction
  • E.G.C. English Girls College in Alexandria, Egypt
  • Egyptian Cuisine, Food and Recipes مأكولات مصرية
  • George Saliba: Seeking the Origins of Modern Science?
  • Internet Scams and Fraud
  • Mistaken for an Arab or Muslim: Absurdities of being a victim in the War on Terror
  • Mistaken Identity: How some people confuse my site for others
  • One People's Terrorist Is Another People's Freedom Fighter
  • Overview of Google's Technologies
  • Photomicroscopy
  • Pseudoscience: Lots of it around ...
  • Resources for using Google Adsense with Drupal
  • Rockwood Conservation Area, Southern Ontario
  • Selected Symbolic Novels And Movies
  • Snorkeling the Red Sea near Jeddah
  • Updates and Thoughts on the Egyptian Revolution of 2011

Recent Content

Most recent articles on the site.

  • Origin Of COVID-19: Natural Spillover, Lab Leak Or Biological Weapon?
  • Kamal Salibi and the "Israel from Yemen" theory
  • How To Upgrade HomeAssistant Core In A Python Venv Using uv
  • Ancestry - Paternal Side
  • Review of Wait Water Saver For Whole House Humidifiers
more

Most Comments

Most commented on articles ...

  • Another scam via Craigslist: offering more than asking price
  • Warning to female tourists thinking of marrying Egyptians
  • Craigslist classified for used car: Cheque fraud scam
  • Winning the lottery scam email: World Cup South African lottery
  • Email Scam: BMW 5 Series car and lottery winning
more

About Khalid

Various little bits of information ...

  • Khalid Baheyeldin: brief biography
  • Presentations and Talks
  • Youtube Videos
  • GitHub Projects
  • Drupal.org Profile
  • Astrophotography @ Flickr

Sponsored Links

Your Link Ad Here

Tags

Android Mobile Ubuntu Sony OnStep OpenWRT Router Ericsson COVID-19 Rogers Coronavirus Arabic Kubuntu Home Assistant GSM Telescope tablet Spectrum Scam Python 419 Laptop Firefox DIY CPU Conspiracy Comet Balkanization backup App
More

© Copyright 1999-2025 The Baheyeldin Dynasty. All rights reserved.
You can use our content under the Terms of Use.
Please read our privacy policy before you post any information on this site.
All posted articles and comments are copyright by their owner, and reflect their own views and opinions, which may not necessarily be consistent with the views and opinions of the owners of The Baheyeldin Dynasty.

Web site developed by 2bits.com Inc.