deepfakes/faceswap · critical · ValueError

This program requires at least python 3.11

Error message

This program requires at least python 3.11

What it means

Module-import-time guard in the top-level tools.py dispatcher: if the interpreter's sys.version_info is below (3, 11) a ValueError is raised immediately. Faceswap's codebase uses Python 3.11+ syntax/features, so older interpreters cannot even parse the tool modules.

Source

Thrown at tools.py:18

#!/usr/bin/env python3
""" The master tools.py script """
import gettext
import os
import sys

from importlib import import_module

# Importing the various tools
from lib.cli.args import FullHelpArgumentParser

# LOCALES
_LANG = gettext.translation("tools", localedir="locales", fallback=True)
_ = _LANG.gettext

# Python version check
if sys.version_info < (3, 11):
    raise ValueError("This program requires at least python 3.11")


def bad_args(*args):  # pylint:disable=unused-argument
    """ Print help on bad arguments """
    PARSER.print_help()
    sys.exit(0)


def _get_cli_opts():
    """ Optain the subparsers and cli options for available tools """
    base_path = os.path.realpath(os.path.dirname(sys.argv[0]))
    tools_dir = os.path.join(base_path, "tools")
    for tool_name in sorted(os.listdir(tools_dir)):
        cli_file = os.path.join(tools_dir, tool_name, "cli.py")
        if os.path.exists(cli_file):
            mod = ".".join(("tools", tool_name, "cli"))
            module = import_module(mod)
            cliarg_class = getattr(module, f"{tool_name.title()}Args")

View on GitHub (pinned to f530cb7508)

Solutions

  1. Install/activate Python 3.11+ and re-run: `python3.11 tools.py ...` or rebuild the virtualenv with it.
  2. If you use conda: `conda create -n faceswap python=3.12 && conda activate faceswap`.
  3. Check what 'python' resolves to (`python --version`, `which python`) and fix PATH/venv activation order.

Example fix

# before
$ python --version
Python 3.10.12
$ python tools.py effmpeg
ValueError: This program requires at least python 3.11

# after
$ python3.11 -m venv fsenv && source fsenv/bin/activate
$ python tools.py effmpeg
Defensive patterns

Strategy: validation

Validate before calling

import sys
if sys.version_info < (3, 11):
    raise SystemExit("Faceswap needs Python 3.11+; you are on " + sys.version.split()[0])

Prevention

When it happens

Trigger: Running `python tools.py ...` (or importing tools.py) with python3.10 or older — e.g. because 'python' resolves to an old system interpreter, or the virtualenv was built from an outdated python, or a distro package was launched with the wrong binary.

Common situations: System default python being 3.8–3.10; activating the wrong conda env; upgrading Faceswap to a version that bumped the minimum Python without rebuilding the venv.

Related errors


AI-assisted analysis of deepfakes/faceswap@f530cb7508 (2026-08-15). Data as JSON: /api/errors/4681e3efba20115b. Report an issue: GitHub.