Update Python to the new version 3.9

ok after mucking around in this whole thing it is apparently not a good idea changing the default of the python to the newer version when installing python3.8/3.9 Home assistant straight up does not like that it will not build the bin folder because it locks itself out of that the home assistant folder

but, why not?

Why would it?

Seriously, Docker is just another piece of software. It’s a way of running other software, but it’s just a piece of software. Why would using it for one thing then force you to run everything else with it?

built a copy and paste tutorial to install Python 3.9 that allows Home Assistant to install
This is intended for a Bare metal reinstall of your OS

Home Assistant Friendly Python 3.9

and if you used this tutorial to build your Home Assistant then it is real easy to copy all the Home Assistant files to another location and re paste them once you redo your Home Assistant with 3.9
nice and clean
Installing Home Assistant with File Sharing

It’s a container.
Once you go through the trouble of installing, configuring, monitoring and tuning a stack, it’s painless to adding additional containers.

:man_shrugging:

1 Like

I am using HA with Python 3.9 and one a week I have problem like this:

> Nov 19 14:16:07 server hass[8363]: OSError: [Errno 24] Too many open files
Nov 19 14:16:07 server hass[8363]: 2020-11-19 14:16:01 ERROR (MainThread) [homeassistant] Error doing job: socket.accept() out of system resource
Nov 19 14:16:07 server hass[8363]: Traceback (most recent call last):
Nov 19 14:16:07 server hass[8363]:   File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 164, in _accept_connection
Nov 19 14:16:07 server hass[8363]:   File "/usr/local/lib/python3.9/socket.py", line 293, in accept
Nov 19 14:16:07 server hass[8363]:     fd, addr = self._accept()
Nov 19 14:16:07 server hass[8363]: OSError: [Errno 24] Too many open files
Nov 19 14:16:07 server hass[8363]: 2020-11-19 14:16:01 ERROR (MainThread) [homeassistant] Error doing job: socket.accept() out of system resource
Nov 19 14:16:07 server hass[8363]: Traceback (most recent call last):
Nov 19 14:16:07 server hass[8363]:   File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 164, in _accept_connection

Is it cased by Python 3.9?

Good and simple procedure. Still having problem with mobile_app (Integration)
after upgrade . Do you know something about it ?

I use this guide for install in python 3.8.5 and work fine, and realy easy

Mi HA only stop for 1 minute

2 Likes

Thank you @igorlemos, just used this guide to update to python 3.9.0 on Raspberry Pi OS, as Python 3.7.3 was too old for homeassistant to run on, it seems to be working.

I’ve heard that using ./configure --enable-optimizations instead of ./configure results in Python running a little faster at the expense of a longer build time, but I’m not really sure if the difference will be noticeable on something like homeassistant

Thanks!!! With your steps i made the upgrade without any problem!

When I install python 3.9 i have some problems , my raspberry version Buster have not libffi.7

And I received this error:

libffi.so.7:
      cannot open shared object file:
        No such file or directory

And other error with numpy like this:


IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.9 from "/srv/homeassistant_venv_3.9.9/bin/python3.9"
  * The NumPy version is: "1.21.2"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: /lib/arm-linux-gnueabihf/libm.so.6: version `GLIBC_2.29' not found (required by /srv/homeassistant_venv_3.9.9/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-arm-linux-gnueabihf.so)

For solved it i use this post:

I think the definitive solution is install raspbian bullseye 11 in my RaspPi.

¿Someone has done it and it works for them?

now HA need python 3.9 in 2022.1 version

Not all of us want to be forced to switch to docker

Nobody is forcing you to switch to Docker

My response was to the person who thought that most HA users ran PiOS - the statistics make it very clear that they don’t, and that most people run in Docker (94.9% currently).

The devs aren’t going to hold things back for the 5.1%.

You might want to have another look at that page. Under installation types, container is quite clearly only 18%

The Container, Home Assistant OS, and Supervised install types are all predicated upon running Home Assistant Core in Docker containers, so adding up those three types, you’re going to get to the total Tinkerer posted.

I’m running core in a venv and I’ve accepted this installation type is far from the most popular, so I’m largely on my own when it comes to maintenance, and ultimately it would probably be in my own best interest to move to a different install method.

The numpy error above I encountered too but had fixed it by telling it to recompile numpy with a difference architecture (fix posted in another thread), was annoying as it took like 15 minutes. If the post above works then use that instead.

I moved to Bullseye now so it just works and no stuffing around needed.

Hi all I get this pyhton error and I don’t understand it …
Logger: aiohttp.server
Source: /usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py:405
First occurred: 14:47:48 (4 occurrences)
Last logged: 15:11:25

Unhandled exception
Traceback (most recent call last):
File “/usr/local/lib/python3.9/asyncio/base_events.py”, line 1183, in _sendfile_fallback
read = await self.run_in_executor(None, file.readinto, view)
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py”, line 514, in start
resp, reset = await task
File “/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py”, line 460, in _handle_request
reset = await self.finish_response(request, resp, start_time)
File “/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py”, line 613, in finish_response
await prepare_meth(request)
File “/usr/local/lib/python3.9/site-packages/aiohttp/web_fileresponse.py”, line 286, in prepare
return await self._sendfile(request, fobj, offset, count)
File “/usr/local/lib/python3.9/site-packages/aiohttp/web_fileresponse.py”, line 99, in _sendfile
await loop.sendfile(transport, fobj, offset, count)
File “/usr/local/lib/python3.9/asyncio/base_events.py”, line 1162, in sendfile
return await self._sendfile_fallback(transport, file,
File “/usr/local/lib/python3.9/asyncio/base_events.py”, line 1192, in _sendfile_fallback
await proto.restore()
File “/usr/local/lib/python3.9/asyncio/base_events.py”, line 263, in restore
self._transport.resume_reading()
File “/usr/local/lib/python3.9/asyncio/sslproto.py”, line 343, in resume_reading
self._ssl_protocol._transport.resume_reading()
AttributeError: ‘NoneType’ object has no attribute ‘resume_reading’

Any ideas to fix it ? Thanks

Thank u very much!
After i update “WARNING: You are using pip version 21.2.4; however, version 22.2.2 is available.
You should consider upgrading via the ‘/srv/homeassistant/bin/python3 -m pip install --upgrade pip’ command.” this, it works perfect!