Bazarr error – externally-managed-environment

ERROR (init:97) – BAZARR requirements.txt installation result: b’error: externally-managed-environment\n\n\xc3\x97 This environment is externally managed\n\xe2\x95\xb0\xe2\x94\x80> To install Python packages system-wide, try apt install\n python3-xyz, where xyz is the package you are trying to\n install.\n \n If you wish to install a non-Debian-packaged Python package,\n create a virtual environment using python3 -m venv path/to/venv.\n Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make\n sure you have python3-full installed.\n \n If you wish to install a non-Debian packaged Python application,\n it may be easiest to use pipx install xyz, which will manage a\n virtual environment for you. Make sure you have pipx installed.\n \n See /usr/share/doc/python3.11/README.venv for more information.\n\nnote: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing –break-system-packages.\nhint: See PEP 668 for the detailed specification.\n’

After upgrading from Debian 11 to Debian 12, my Bazarr service would not start. Initially, I was thrown off by messaging that indicated that Bazarr does not work with Python versions above 3.10.x – but I soon learned that to be false. I’m running version 1.2.4 of Bazarr, the latest general release at the time of this writing. Trying to solve this problem led me down a rabbit hole of various issues and potential solutions, all centered around creating a Python venv and obtaining Setuptools in a version different than what system-wide Debian provides. None of it quite worked.

Here is what fixed my problem:

  1. Install python3-full: sudo apt install python3-full
  2. Rename the EXTERNALLY-MANAGED file: sudo mv /usr/lib/python3.11/EXTERNALLY-MANAGED /usr/lib/python3.11/EXTERNALLY-MANAGED.old
  3. Download the latest Bazarr zip and expand it over my existing directory
    • wget
    • unzip /opt/bazarr/ (or wherever you have bazarr located)
  4. Install unrar: sudo apt install unrar
  5. Create a venv in my bazarr directory
    • cd /opt/bazarr (or wherever you have bazarr located)
    • python3 -m venv .venv
    • source .venv/bin/activate
  6. Install the requirements in the venv: python3 -m pip install --break-system-packages -r requirements.txt
  7. Finally, start Bazarr: python3 /opt/bazarr/
  8. Check to see if it starts successfully, if so, CTRL+C to stop it, and start the service version: sudo systemctl start bazarr

Home Assistant: Unable to find service

In my Home Assistant setup, I created an SMTP notification that would email my phone’s SMS gateway when certain conditions were met. Except it didn’t work.

When monitoring the log file, I found the following when the condition was supposed to trigger:

WARNING (MainThread) [homeassistant.core] Unable to find service notify/txt_smeg

When I did additional digging in the log file, I found this:

ERROR (Thread-6) [homeassistant.components.notify.smtp] Login not possible. Please check your setting and/or your credentials
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/notify/", line 120, in connection_is_valid
    server = self.connect()
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/notify/", line 113, in connect
    mail.login(self.username, self.password)
  File "/usr/lib/python3.5/", line 729, in login
    raise last_exception
  File "/usr/lib/python3.5/", line 720, in login
  File "/usr/lib/python3.5/", line 641, in auth
    raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, b'5.7.8 Error: authentication failed:')
 ERROR (MainThread) [homeassistant.components.notify] Failed to initialize notification service smtp

But everything in my configuration looked OK. I checked and the password works. Restarting the Home Assistant service resulted in the same error.

After seeing this discussion where a machine restart magically fixes this problem, I restarted my entire device. After it booted back up, the notification worked correctly. My only guess is that smtplib must keep a cache somewhere, or holds something in memory across application re-loads.