Python

Verified against ChatGPT · 2026-07-26

Diagnose a Python dependency or virtual environment conflict systematically

A structured diagnostic prompt for dependency and venv breakage that requires a stated root-cause hypothesis and cited evidence before proposing a fix, instead of jumping straight to pip install --upgrade.

ChatGPT (GPT-5.1)Claude (Sonnet 4.6)Claude CodePerplexity4 fillable variables

The prompt

Ready to copy — highlighted parts are example details you can swap.

Diagnose this Python environment or dependency problem. Do not propose a fix until you've stated a specific hypothesis for the root cause — "try reinstalling" is not a diagnosis, it's a guess dressed up as one.

ERROR
ImportError: cannot import name "BaseSettings" from "pydantic" — happens after upgrading a different package.

ENVIRONMENT
Windows 11, Python 3.12, venv created with python -m venv .venv

PACKAGE MANAGER IN USE
uv

RECENT CHANGE
Ran "uv add fastapi" yesterday to add a new dependency; everything worked before that.

DIAGNOSTIC PROCESS
1. Identify the failure category first: a version conflict between two packages' requirements, a missing system-level dependency (compiler, system library), a wrong or stale virtual environment being activated, a Python version mismatch (a package with no wheel for this Python version), or a corrupted/partial install. Cross-reference Ran "uv add fastapi" yesterday to add a new dependency; everything worked before that. against the error — most environment breakage traces to something that changed recently, and that's the first place to look, not a random guess. State which category this looks like and why, citing the specific line in the error output.
2. Ask for exactly the information you're missing to confirm the hypothesis, if anything — pip list output, the package manager's version, which python, or the lockfile diff — rather than guessing further past the point where evidence would resolve it.
3. Once confirmed, give the fix as ordered, copy-pasteable commands, not a paragraph description. Note which command is destructive (e.g. deleting a virtual environment) before it runs, and give the non-destructive alternative first if one exists.
4. Give one prevention step specific to this failure category — pinning a version range, adding a lockfile, using a resolver like uv or pip-tools for reproducible installs — not a generic "keep dependencies updated."
5. If the fix involves recreating a virtual environment, state exactly what gets lost in the process (any package installed manually outside the lockfile, any editable install pointing at a local path) so nothing has to be silently rediscovered and reinstalled by trial and error afterward.

CONSTRAINTS
- Don't suggest pip install --upgrade or --force-reinstall as a first move; that can mask the real problem and break other packages pinned lower in the dependency tree.
- If the fix could change behavior elsewhere in the project (a major version bump), say so and ask before assuming it's fine to proceed automatically.
- If two proposed fixes would both resolve the immediate error but with different long-term consequences (pinning an older version versus upgrading and fixing the code that broke), present both and say which you'd pick and why, rather than silently choosing one.

OUTPUT FORMAT
Root cause hypothesis, then confirming evidence needed if any, then exact fix commands, then one line on preventing this category next time, then anything lost if the fix recreates the environment.

Customize

Optional — swap in your own details for the highlighted parts above.

Why this works

Forcing a stated hypothesis, with a cited line from the error output, before any fix is proposed directly prevents the most common LLM failure mode on dependency errors: pattern-matching the error text to a generic "reinstall your packages" answer that either doesn't address the real conflict or actively masks it by upgrading something that was correctly pinned for a reason nobody documented. The recent_change field is the single highest-leverage piece of information in this whole prompt, because in practice the overwhelming majority of "it just started breaking" dependency errors trace directly to the last thing that changed — a new package added that silently bumped a shared transitive dependency, an unrelated system update that replaced a system compiler — and naming that change turns the model's search space from "every possible cause" into "check this specific hypothesis first," which is exactly how an experienced engineer actually debugs the same problem. Naming the real failure categories — a missing wheel for the installed Python version, a stale virtual environment still pointing at an old interpreter, a native compiler dependency the OS doesn't have — gives the model concrete diagnostic branches to reason through instead of one catch-all response that sounds confident regardless of which category actually applies. The explicit ban on leading with --force-reinstall reflects real practitioner knowledge: in a project with pinned versions, a force-reinstall of one package can silently pull in incompatible versions of its own dependencies, turning one broken import into three, which is a worse state than the one the fix was supposed to resolve. Requiring both viable fixes to be surfaced when they carry different long-term consequences matters because the fastest fix for the immediate error — pinning back to a version that worked — and the fix that actually keeps the project current — upgrading and adjusting the code that broke — are not the same recommendation, and silently picking one without saying so denies whoever's running this diagnosis the chance to weigh urgency against technical debt themselves, which is a decision that depends on context the diagnostic prompt alone can't fully see.

Verified against

ChatGPT GPT-5.1 · 2026-07-26

Changelog

  • 2026-07-26 Initial publish, verified against ChatGPT (GPT-5.1) on a uv-managed Python 3.12 project.

Need this built into your business?

If a prompt isn't enough — custom software, built and maintained for you — that's Scult's day job.

EXPLORE CUSTOM SOFTWARE
All Python prompts

Check your AI visibility

One URL in, a 0–100 score and the exact fixes out.

RUN THE CHECK

Browse all the tools

15 tools across six categories
13 of them never send your data anywhere

Free · No signup · No trial clock

SEE THE DIRECTORY