FS#78774 - [home-assistant] Unable to install package sqlalchemy==2.0.15: error: externally-managed-environment

Attached to Project: Arch Linux
Opened by Max Pray (synthead) - Tuesday, 13 June 2023, 21:28 GMT
Last edited by Maxime Gauduin (Alucryd) - Saturday, 17 June 2023, 17:59 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Maxime Gauduin (Alucryd)
Alexander Epaneshnikov (alex19EP)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 3
Private No

Details

Description:

When starting HA 1:2023.6.1-1, I see messages in /var/log/hass/home-assistant.log that look like this:

https://gist.githubusercontent.com/synthead/ec10aadcef974f734334c95aa8efb253/raw/121cd1cc09ff9130bfe44292e81cac0c95f582fc/gistfile1.txt

Here's the plain text so it's searchable here:

2023-06-13 13:41:33.255 ERROR (SyncWorker_0) [homeassistant.util.package] Unable to install package sqlalchemy==2.0.15: error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try 'pacman -S
python-xyz', where xyz is the package you are trying to
install.

If you wish to install a non-Arch-packaged Python package,
create a virtual environment using 'python -m venv path/to/venv'.
Then use path/to/venv/bin/python and path/to/venv/bin/pip.

If you wish to install a non-Arch packaged Python application,
it may be easiest to use 'pipx install xyz', which will manage a
virtual environment for you. Make sure you have python-pipx
installed via pacman.

This appears to complain about these missing python libs at these specific versions:

- PyQRCode 1.2.1
- PyTurboJPEG 1.6.7
- fnv-hash-fast 0.3.1
- janus 1.0.0
- psutil-home-assistant 0.0.1
- pyotp 2.8.0
- sqlalchemy 2.0.15

Additionally, the deps/ directory doesn't seem to populate when HA is started. If I move this dir to deps.backup/ and restart HA via systemctl, the directory will be created with the correct permissions, but it will remain empty. It appears as if HA isn't installing the python libs, and is complaining about them not existing.

Additional info:
* home-assistant 1:2023.6.1-1

Steps to reproduce:

1. Install home-assistant
2. Start home-assistant.service via systemctl

Marking as critical in the scope of home-assistant because there is a problem that breaks HA on package upgrade. Feel free to adjust this if you feel that this is incorrect in some way.
This task depends upon

Closed by  Maxime Gauduin (Alucryd)
Saturday, 17 June 2023, 17:59 GMT
Reason for closing:  Fixed
Additional comments about closing:  2023.6.2-1
Comment by Toolybird (Toolybird) - Tuesday, 13 June 2023, 22:02 GMT
Yeah, currently it seems more horked than usual...
Comment by Toolybird (Toolybird) - Tuesday, 13 June 2023, 22:13 GMT
Actually, it seems to be caused by new python-3.11.3-2. Downgrading back to python-3.11.3-1 makes hass start up properly...
Comment by Max Pray (synthead) - Tuesday, 13 June 2023, 22:21 GMT
Can confirm! Downgrading to python-3.11.3-1 also makes it work here, too.
Comment by loqs (loqs) - Tuesday, 13 June 2023, 22:37 GMT
What if you add --skip-pip to the /usr/bin/hass invocation in home-assistant.service does it then just fail due to version mismatches?
Comment by Christian Heusel (gromit) - Tuesday, 13 June 2023, 22:44 GMT
@Toolybird, that is by design and a very nice feature of python-3.11.3-2 imo.
See https://lists.archlinux.org/archives/list/arch-general%40lists.archlinux.org/thread/7V7IE2KT2Z75CTTABQIYHFXVXKKBDS5N/ for some background about PEP668

How this package can be fixed however is a totally different question :p

Edit: okay, something is borked about the link, but only in the preview :P
Comment by Toolybird (Toolybird) - Tuesday, 13 June 2023, 23:07 GMT
@gromit, I'm well aware of  FS#78413  :) Was just pointing out the cause of the breakage..

PS: fixed the link
Comment by Maxime Gauduin (Alucryd) - Friday, 16 June 2023, 10:43 GMT
So I've been experimenting, you'll find a new package in extra-testing. This one uses a new approach, it only contains a wheel to bootstrap the installation. Upon starting the service, a venv is created in /var/lib/hass/.venv, the wheel is installed inside of it, then the server is started as usual. This is more or less the official way of installing HA core from PyPi.

This still fails the first run as before, but now with a different error, so even the official way is kinda crap, but at least we don't have to worry about deps and versions anymore, and the whole installation is now self-contained. Please try the new package and report back, it should work fine with existing installations, you should be able to delete the deps folder in /var/lib/hass afterwards as additional packages will be installed in the venv now.
Comment by Matthieu Helleboid (higgins) - Saturday, 17 June 2023, 07:40 GMT
Installed version 2023.6.2-1 from extra-testing and restart home-assistant
Worked like a charm on my installation (at the first run)
Deleted /var/lib/hass/deps manually before installation
Comment by Maxime Gauduin (Alucryd) - Saturday, 17 June 2023, 17:58 GMT
Nice, thanks for the feedback, I'll move it to extra.

Loading...