Update Python to the new version 3.9


Three out of four methods use Docker, where it’s not a problem - most HA users don’t run RPi OS :wink:

Oh, and unless you’re trying to directly run locally installed software, switching to Docker is trivial.


There’s probably a fair share of people using Raspberry Pi OS, but most of them run HA supervised which doesn’t care about your python version. People using venv are the minority and most of them use it because they have enough experience with linux/python and don’t have any issue with updating a python version. The other people that use venv are in my experience using venv because they started when the docker installs didn’t exist and never bothered to switch to the docker installs or people that read a tutorial somewhere that advised them to install it in a venv or people that simply choose the wrong install method because they are afraid of docker or dimilar things.

When you live at the wrong end of a very expensive, metered satellite link, switching to docker isn’t quite so trivial.

Then I’m afraid you’re just going to have to roll with manually installing Python every 12 months :wink:

Or take this sort of dismissive attitude as a hint that maybe I should give up on Homeassistant after 4 years.

1 Like

Not at all, but it is what it is. You’re between a rock and a hard place, and the only practical solution is for you to up-skill. The developers aren’t going to change their mind because a minority of users, using a method they’ve tagged as an expert installation method, have issues.

Learning how to upgrade Python, or even just following any of the many guides (see below), is really the only option you’ve got here:

Most of these are the same basic process, and will work for version 3.8, 3.9, 3.10 and so on. Heck, I ended up writing a script I can run that does all the heavy lifting for me.


Another more basic question:
I have a Pi core installation i.e. a user “pi” and a user “homeassistant” with its own virtual env for a fresh python3.8.6 installation.
In my understand the venv python (under /srv/homeassistant) has still access to all modules with I install as user “pi” (under /usr/local/lib/python3.8/site-packages) ?

But if I check sys.path in the my venv Python:

>>> import sys
>>> sys.path
['', '/usr/local/lib/python38.zip', '/usr/local/lib/python3.8', '/usr/local/lib/python3.8/lib-dynload', '/srv/homeassistant/lib/python3.8/site-packages']

there is no path to …site-packages? Is this normal?
As an example I installed module lxml as user pi:

sudo pip3 install lxml

but when switch to venv “homeassistant” the module is not there…?

No, you need to install the modules inside the venv.
I’m sorry, don’t take it as an attack, but you are a prime example of people who should not be using the venv install method as it seems you don’t have the necessary skills and knowledge.

Yes maybe I have only 77% knowledge but I am optimistic :wink:

So if venv is really closed why do I see a /usr/local/lib/python3.8 directory in my venv Python sys.path?

From the official python docs here.

To create a virtual environment, decide upon a directory where you want to place it, and run the venv module as a script with the directory path:

python3 -m venv tutorial-env

This will create the tutorial-env directory if it doesn’t exist, and also create directories inside it containing a copy of the Python interpreter, the standard library, and various supporting files.

I’m sorry but from your replies, I doesn’t sound like you know how a venv works at all.

Why make your life harder than it needs to be? Is there a specific reason that you need to run HA in a venv?

I am sorry but you seem to be unaware of the standard install procedure of HA as a core installation?


The fact that you cannot answer my very specific question but just pointing to the official python docs (which I know from my 77%) indicates to me that your knowledge might be also <100%.

Never mind, I got python 3.8.6 installed now fine, it was cumbersome but with the help of this thread and some tricks HA is now up and running fine.

I’m more than aware of the venv installation, I used it myself 2 years ago before I switched to core in docker. But what do you want to tell me with this??
You still did not answer my question why you choose to install it in a venv? Is there a specific reason?
Installation in a venv is not the recommended installation method, in fact the official docs recommend it for developers and it’s an alternative install method -> see here.

??? The answer to your specific question is right in the quote I posted from the docs. But I’ll quote the relevant part again for you:

Yes as written there its an alternative install method. The reason is simply that my Pi should run other progs on top of HA and I have 0% knowledge of docker which you need for the “closed” system.

I am not sure whether “site-packages” are part of the the “standard library”? And again, if everything is copied why is there still a sys.path pointer to the python install outside the venv… i.e. in /usr/local/lib?

You need very little knowledge to use the Docker method - less than you need for using pip :wink:

1 Like

Maybe but can I run any prog in a docker env? For example I want the pi-hole DNS blocker active all the time.

Sure, they have a Docker image for that. Even if they didn’t you could still install that outside of Docker.

Using Docker doesn’t mean everything has to go in Docker.

This thread needs to cool down a few degrees. There is no need to point out who knows what %.

The python documentation is a bit confusing. It says that each virtual environment has its own binary. I think this is misleading, it links to a specific binary that already exists on the system. In this case, your virtual environment points to


Okay and that helps me how? I don’t do anything special for permissions that I do with 3.7 versions

The path to site-packages that you posted goes to ‘/srv/homeassistant/lib/python3.8/site-packages’ which is the venv.
Sorry for the misinformation about the libraries being copied to the venv, when it’s actually a link as MatthewFlamm pointed out.
And sorry if my posts were a bit rude, I just feel like your life would be easier with a docker install :slight_smile: as Tinkerer said there’s a docker image for pi-hole, in fact I had it running like this in the past, before I moved Pi-hole and some other network related stuff to a separate Pi.

1 Like

Thank you. This worked perfectly…

1 Like