soxoj/maigret · critical · ImportError

Missing required dependency while starting Maigret. If inst

Error message

Missing required dependency while starting Maigret.

If installed from PyPI:
    pip install -U maigret

If running from a cloned repository:
    pip install -e .

Then run Maigret as:
    python -m maigret <username>

What it means

Raised by maigret/__init__.py when `from .checking import maigret` fails with an ImportError, meaning Maigret's own runtime dependencies (or submodules) could not be imported. The package guards its top-level import so users get actionable install instructions instead of a raw internal traceback. It almost always means the package is being run from a source checkout without dependencies installed, or a broken/partial install.

Source

Thrown at maigret/__init__.py:13

"""Maigret"""

__title__ = 'Maigret'
__package__ = 'maigret'
__author__ = 'Soxoj'
__author_email__ = 'soxoj@protonmail.com'


from .__version__ import __version__
try:
    from .checking import maigret as search
except ImportError as e:
    raise ImportError(
        "Missing required dependency while starting Maigret.\n\n"
        "If installed from PyPI:\n"
        "    pip install -U maigret\n\n"
        "If running from a cloned repository:\n"
        "    pip install -e .\n\n"
        "Then run Maigret as:\n"
        "    python -m maigret <username>"
    ) from e
from .maigret import main as cli
from .sites import MaigretEngine, MaigretSite, MaigretDatabase
from .notify import QueryNotifyPrint as Notifier

View on GitHub (pinned to 41674631a9)

Solutions

  1. Run `pip install -U maigret` (PyPI install) or `pip install -e .` from the cloned repository root to (re)install dependencies.
  2. Recreate/activate the correct virtualenv and reinstall: `python -m venv venv && source venv/bin/activate && pip install -e .`
  3. Inspect the original ImportError chain (`raise ... from e`) to see which specific module is missing and `pip install` it.
  4. If the install persists in failing, clear the pip cache / reinstall with `--force-reinstall`.

Example fix

# before
python -m maigret someuser
# ImportError: Missing required dependency while starting Maigret...

# after
pip install -e .
python -m maigret someuser
Defensive patterns

Strategy: validation

Validate before calling

import importlib.util, subprocess, sys

def ensure_maigret_importable():
    if importlib.util.find_spec("maigret") is None or importlib.util.find_spec("aiohttp") is None:
        subprocess.check_call([sys.executable, "-m", "pip", "install", "-U", "maigret"])

Type guard

def maigret_ready() -> bool:
    try:
        import maigret  # noqa: F401
        return True
    except ImportError:
        return False

Try / catch

try:
    import maigret
except ImportError as e:
    raise SystemExit(
        "maigret deps missing — run `pip install -U maigret` or `pip install -e .`"
    ) from e

Prevention

When it happens

Trigger: Importing `maigret` (e.g. `import maigret` or `python -m maigret`) when `maigret.checking` or one of its transitive imports (aiohttp, requests, etc.) is missing; running from a cloned repo without `pip install -e .`; a truncated/partial PyPI install; a Python version incompatible with a dependency causing import failure.

Common situations: Cloning the repo and running `python -m maigret` directly; stale virtualenv created before new dependencies were added in a recent release; system Python vs venv mismatch; installing with `--no-deps` or a broken pip cache.


AI-assisted analysis of soxoj/maigret@41674631a9 (2026-08-27). Data as JSON: /api/errors/871b764ac8fd9341. Report an issue: GitHub.