Update Python to the new version 3.9

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?

https://www.home-assistant.io/docs/installation/raspberry-pi/

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

2 Likes

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

Thank you!
It dod not work for me flawless… but it worked out…

After upgrading the first time home assistant started, my PI stopped responding after 50 minutes on 1 python3 process on 100% cpu power.

After reboot, 2 python3 processes on 100%… and home assistant stayed on status “home assistant is starting, not all bla bla bla”…
That took another hour… en suddenly it was started… reboot… homeassistant again normal and responsive and quick boot…

Does this make sense? Why was the first and second boot so slow en problematic?

after all, a good upgrade…

1 Like

After you create a new virtual environment and start home assistant, all the packages you need will be installed. This can take a long time depending on how many integrations you have, which integrations you have, internet speed, cpu, etc.

2 Likes

That is a clear one!, the freeze probably was a coincidence…

1 Like

Thank you igorlemos. The procedure works perfectly!
Just for the “rm” commands I had to put a “sudo” in front.

1 Like

I had this issue. I had used update-alternatives to set the systemwide python3 to point to my newly compiled python3.8, but this seemed to cause issues. I undid the update-alternatives (you may need to re-set your Python 3.7 or older installation as the main alternative after this to get python3 working again) and then everything worked.

Actually even when following the documentation on the venv installation on Python the ugrade process can be cumersome:

  1. there seem to be no pre-compiled binary for my Raspberry 3 so the complete phyton3.8 installation needs to compile everything. This step was ok in my case.
  2. After that you create your virtual env and hass needs to re-install all needed modules for HA which, again for some modules need another compiler action. This failed for me for some modules (i.e. modules for my BT Thermostats, some basic modules like lxml and others…)

They only way out was to simply copy the modules over from the previous 3.7 installation. Now, fingers crossed, everything works but I hope the team is not switching to Python3.9 anytime soon :wink:

And yes, maybe Docker might be simpler after all :wink:

1 Like

They will drop support for Python 3.8 when Python 3.10 is officially released by the Python maintainers. Home Assistant targets the two most recent versions of Python (so as of today, 3.8 and 3.9).

Python 3.10 is currently due October 2021; after it is made final, the next subsequent release of Home Assistant should deprecate 3.8, with support for it completely removed after another 2 months.

1 Like