Describe the bug
When running Bazarr with Python 3.13+, the following errors occur due to deprecated or removed modules:
- SQLAlchemy: The bundled SQLAlchemy library is outdated and fails with the following error due to stricter subclassing checks in Python 3.13+:
AssertionError: Class <class 'sqlalchemy.sql.elements.SQLCoreOperations'> directly inherits TypingOnly but has additional attributes {'__firstlineno__', '__static_attributes__'}
- imghdr: The imghdr module has been removed in Python 3.13, causing crashes in deathbycaptcha.
- pipes.quote: The pipes module has been removed, leading to failures in libfilebot.
These issues prevent Bazarr from starting successfully on systems with Python 3.13+.
To Reproduce
- Run Bazarr on a system with Python 3.13 or later.
- Start the Bazarr service.
- Observe crashes in the logs.
Expected behavior
Bazarr should start without errors and function correctly when running on Python 3.13 or later.
Software:
- Bazarr: v 1.5.0
- Radarr v 5.16.3.9541
- Sonarr v 4.0.11.2680
- OS: Arch Linux (kernel 6.12.6)
- Python: v 3.13.1
Additional context
I initially discovered these issues on Bazarr v1.4.5. After updating to v1.5.0, I confirmed the problems persist.
To resolve the issues locally, I applied the following fixes:
-
SQLAlchemy: The bundled sqlalchemy.util was replaced with the latest version from the system-installed SQLAlchemy:
cp -R /usr/lib/python3.13/site-packages/sqlalchemy/util/* /usr/lib/python3.13/site-packages/bazarr/libs/sqlalchemy/util/
-
imghdr:
- Replaced imghdr.what functionality with python-magic:
import magic
def what(_, img):
mime = magic.Magic(mime=True)
img_type = mime.from_buffer(img)
if img_type.startswith("image/jpeg"):
return 'jpeg'
elif img_type.startswith("image/png"):
return 'png'
elif img_type.startswith("image/gif"):
return 'gif'
return None
- Saved file as
imghdr.py in the custom_libs folder
- Updated deathbycaptcha.py to import the new
what function:
- Replaced
pipes.quote with shlex.quote in main.py located in custom_libs/libfilebot:
Describe the bug
When running Bazarr with Python 3.13+, the following errors occur due to deprecated or removed modules:
AssertionError: Class <class 'sqlalchemy.sql.elements.SQLCoreOperations'> directly inherits TypingOnly but has additional attributes {'__firstlineno__', '__static_attributes__'}These issues prevent Bazarr from starting successfully on systems with Python 3.13+.
To Reproduce
Expected behavior
Bazarr should start without errors and function correctly when running on Python 3.13 or later.
Software:
Additional context
I initially discovered these issues on Bazarr v1.4.5. After updating to v1.5.0, I confirmed the problems persist.
To resolve the issues locally, I applied the following fixes:
SQLAlchemy: The bundled sqlalchemy.util was replaced with the latest version from the system-installed SQLAlchemy:
cp -R /usr/lib/python3.13/site-packages/sqlalchemy/util/* /usr/lib/python3.13/site-packages/bazarr/libs/sqlalchemy/util/imghdr:
imghdr.pyin thecustom_libsfolderwhatfunction:pipes.quotewithshlex.quoteinmain.pylocated incustom_libs/libfilebot: