Description
CaptchaGenerator._is_manim_available() (generator.py:223) checks for the manim executable via shutil.which("manim"):
def _is_manim_available(self) -> bool:
manim_bin = shutil.which("manim")
if not manim_bin:
return False
return True
This makes CaptchaAutoGenerator.start() return False whenever the venv's bin/ directory is not on PATH, which is the normal case for a systemd service invoking /path/to/.venv/bin/python directly: systemd's default PATH is /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin and does not include the venv. Manim is installed and fully importable, but the generator refuses to start.
Why the check looks unnecessary
The library never invokes the manim entry point. The only execution path is generator.py:192, which runs the current interpreter with the launcher script:
cmd = [sys.executable, str(self.MANIM_LAUNCHER), json_manim_data]
Also, generator.py:41 already does import manim at module level, so an actually-missing manim would raise ImportError at import time, long before this check ever runs. The executable is being used as a proxy for "is manim installed?", but it answers a different question than the one that matters.
Suggested fix
Check module importability instead of the executable, since that is what the subprocess actually needs:
def _is_manim_available(self) -> bool:
return importlib.util.find_spec("manim") is not None
(importlib.util is already used this way in manim_launcher.py.)
Secondary issue: silent failure
start() returns False with no log entry explaining why — unavailable versus already running are indistinguishable from the consumer's side. A logger.error("Manim module not found") on the unavailable path would make this diagnosable from logs instead of requiring a read through the library source.
Environment
- manim-captcha 1.2.2
- manim 0.19.2
- Python 3.14
- Arch Linux, running under systemd
Description
CaptchaGenerator._is_manim_available()(generator.py:223) checks for themanimexecutable viashutil.which("manim"):This makes
CaptchaAutoGenerator.start()returnFalsewhenever the venv'sbin/directory is not onPATH, which is the normal case for a systemd service invoking/path/to/.venv/bin/pythondirectly: systemd's defaultPATHis/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binand does not include the venv. Manim is installed and fully importable, but the generator refuses to start.Why the check looks unnecessary
The library never invokes the
manimentry point. The only execution path isgenerator.py:192, which runs the current interpreter with the launcher script:Also,
generator.py:41already doesimport manimat module level, so an actually-missing manim would raiseImportErrorat import time, long before this check ever runs. The executable is being used as a proxy for "is manim installed?", but it answers a different question than the one that matters.Suggested fix
Check module importability instead of the executable, since that is what the subprocess actually needs:
(
importlib.utilis already used this way inmanim_launcher.py.)Secondary issue: silent failure
start()returnsFalsewith no log entry explaining why — unavailable versus already running are indistinguishable from the consumer's side. Alogger.error("Manim module not found")on the unavailable path would make this diagnosable from logs instead of requiring a read through the library source.Environment