Fix Stable Diffusion A1111 Missing pkg_resources (2026)
You haven’t broken anything. You didn’t mess up the install. I’ve seen this exact wall of red text panic dozens of people in the A1111 community since early 2026 — and every single time, the root cause is the same upstream Python packaging change, not anything the user did wrong. The Stable Diffusion A1111 missing pkg resources error takes three file edits and about five minutes to fix permanently.
Stable Diffusion A1111 missing pkg resources is a launch-blocking error triggered when
setuptoolsv82+ removes its built-inpkg_resourcesmodule, which legacy dependencies like OpenAI CLIP still require during wheel compilation. For example, when you runwebui-user.bat, pip spins up an isolated build isolation subprocess that fetches the latestsetuptoolsfrom PyPI — which no longer shipspkg_resources— causing A1111 to abort before the WebUI ever opens.
As of April 2026, this issue is confirmed in GitHub Discussion #17375 and Issue #17306 on the official AUTOMATIC1111 repository AUTOMATIC1111 GitHub Discussion #17375, affecting every fresh install and venv directory reset performed on an unmodified webui-user.bat on Windows after the setuptools v82 release window.
What Is the Quick Fix for the Stable Diffusion A1111 Missing pkg_resources Error?
Quick Answer
Pin setuptools below version 82 using a pip constraints file before A1111 rebuilds its virtual environment. Create pip-constraints.txt in your webui root containing setuptools<82, reference it in webui-user.bat via set PIP_CONSTRAINT=pip-constraints.txt, delete the venv folder, then relaunch. The WebUI will rebuild cleanly in under five minutes.
That’s the whole fix. Everything below explains why it works, walks you through each file edit with exact copy-paste content, and covers the edge cases I’ve seen trip people up after the main steps succeed.
Why Does A1111 Suddenly Show “No Module Named pkg_resources”?
In my experience, the most disorienting part of this error is that it appears without warning on a setup that was working perfectly the day before. Nothing in your A1111 folder changed. No Windows update touched your Python install. Yet the WebUI refuses to launch.
The culprit is a breaking change in setuptools version 81/v82+, released in early 2026. For over a decade, setuptools bundled pkg_resources as part of itself — it was the standard way Python packages declared and resolved their own dependencies at runtime. In v82, the maintainers removed this legacy module entirely. AUTOMATIC1111 GitHub Issue #17306
The reason your old venv survived is simple: it was built before v82 shipped. The moment you delete that venv — for any reason, including a routine reinstall or troubleshooting step — pip builds a fresh environment and pulls setuptools v82+ off PyPI. That’s when the error appears.
The Exact Error Log You Are Seeing
Here is the verbatim error from the official bug report. If your terminal matches this pattern, you’re in the right place:
Installing clip
Traceback (most recent call last):
File "C:\sd\stable-diffusion-portable-main\launch.py", line 53, in main()
...
File "<string>", line 3, in <module>
ModuleNotFoundError: No module named 'pkg_resources'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed to build 'https://github.com/openai/CLIP/archive/d50d76daa670286dd6cacf3bcd80b5e4823fc8e1.zip'
RuntimeError: Couldn't install clip.
The key signature is [end of output] immediately followed by RuntimeError: Couldn't install clip. That tells you the failure happened inside pip’s isolated build subprocess — not in your main Python environment — which is exactly why reinstalling Python at the system level does nothing.
Why the Build Isolation Trap Catches Everyone
Here’s the part that confused me when I first diagnosed this. Even if you manually downgrade setuptools in your main Python install, it doesn’t help. When pip builds the openai/CLIP wheel from source, it creates a completely separate throwaway Python virtual environment with its own package set. That isolated environment independently downloads the latest setuptools from PyPI — currently v82+ — regardless of what your system Python has.
The only way to fix it cleanly is to tell pip to apply a version cap before it builds that isolated environment. That’s exactly what the PIP_CONSTRAINT environment variable does.
How Do You Fix the Stable Diffusion A1111 Missing pkg_resources Error Step by Step?
I’ll walk you through this exactly as I do it on a fresh Windows machine. No Python knowledge required — you’re editing two text files and deleting one folder.
Step 1 — Create pip-constraints.txt in Your WebUI Root
Open File Explorer and navigate to your stable-diffusion-webui folder — the top-level folder that contains webui-user.bat, launch.py, and the models subfolder. Right-click inside that folder → New → Text Document. Name it exactly:
pip-constraints.txt
Open it with Notepad and paste in these three lines:
setuptools<82
pip<24
wheel<0.45
Save and close. This file caps all three core build tools at versions that include pkg_resources and are fully compatible with A1111’s dependency chain. The pip<24 and wheel<0.45 caps are belt-and-suspenders — they prevent co-upgrade side effects I’ve observed in a small number of edge-case installs.
Critical: Make sure Windows didn’t save the file as pip-constraints.txt.txt. Open the folder in File Explorer with “File name extensions” turned on (View → Show → File name extensions) to verify the name is correct.
Step 2 — Register the Constraint File in webui-user.bat
Right-click webui-user.bat → Open with → Notepad. You’ll see a file that looks roughly like this:
@echo off
set PYTHON=
set GIT=
set VENV_DIR=
set COMMANDLINE_ARGS=
call webui.bat
Add one line directly above call webui.bat:
set PIP_CONSTRAINT=pip-constraints.txt
Your edited file should now end with:
set PIP_CONSTRAINT=pip-constraints.txt
call webui.bat
Save and close. This environment variable is read by pip automatically during every install and build operation — including inside the isolated subprocess that builds CLIP. That’s what makes the fix work where system-level downgrades fail.
Step 3 — Delete the Broken venv Folder
In your stable-diffusion-webui directory, find the folder named venv. Delete it entirely — send it to the Recycle Bin or Shift+Delete. Don’t worry: this folder is fully regenerated on next launch. Your models, embeddings, LoRA files, and outputs are stored elsewhere and are completely unaffected.
Step 4 — Relaunch webui-user.bat
Double-click webui-user.bat. Watch the terminal output carefully. You should see pip installing setuptools at a version below 82 (e.g., 69.x or 74.x), CLIP building successfully without the ModuleNotFoundError, and the WebUI browser tab opening at http://127.0.0.1:7860. The full rebuild typically takes 3–8 minutes depending on your connection speed. AUTOMATIC1111 GitHub Discussion #17375
Step 5 (Fallback) — Manually Pin setuptools Inside the venv
In my tests, Steps 1–4 resolve the issue for the vast majority of users. But if you still see the error after a clean rebuild, it likely means the PIP_CONSTRAINT variable isn’t being picked up at the right moment in A1111’s launch sequence. The manual fallback:
- Run
webui-user.batonce — let it error out and create thevenvfolder - Open a Command Prompt in your webui directory
- Run the command below
- Relaunch
webui-user.bat
venv\Scripts\pip install setuptools==69.5.1
Version 69.5.1 is a stable, widely-tested release confirmed to ship pkg_resources intact. I’ve used this fallback on three machines where the constraint file approach had a path resolution issue.
Step 6 (Secondary Error) — Fix “Repository Not Found: stablediffusion.git”
On some installs, fixing the CLIP error reveals a second error buried further in the log: Repository not found: stablediffusion.git. This means the repositories subfolder has a broken or missing clone. Fix it by deleting the repositories subfolder, then running:
set COMMANDLINE_ARGS=--skip-install
webui-user.bat
Once the repository clones successfully, remove the --skip-install flag from COMMANDLINE_ARGS so future extension installs work normally.
What Are the Wrong Fixes to Avoid for the Stable Diffusion A1111 Missing pkg_resources Error?
The mistake I see most often in forums is users reaching for the most drastic solution first — reinstalling Python, reinstalling Windows, even reformatting. None of those address the actual problem. Here is a reference table of the fixes that don’t work and exactly why:
| ❌ Wrong Approach | Why It Fails |
|---|---|
pip install pkg_resources directly | The PyPI stub is deprecated and installs nothing functional; pkg_resources is not a standalone installable package |
| Reinstalling Python at the system level | The setuptools version problem lives in pip’s isolated build subprocess, not your system Python — a system reinstall doesn’t touch it |
Running git pull to upgrade A1111 | The webui source code is not the problem; the issue is in the PyPI package ecosystem, not the A1111 repository |
Setting --skip-install as a permanent flag | Prevents A1111 from installing new extensions and receiving dependency updates; only use it for the repository recovery step in Step 6 |
| Downgrading Python to 3.10 | Python version is not the trigger; the setuptools v82 breaking change affects all Python versions equally during build isolation |
The core insight from Stack Overflow — No module named pkg_resources is that pkg_resources was never a standalone package — it was always a module that shipped inside setuptools. Attempting to install it separately has never worked and never will. The only correct approach is ensuring the setuptools version being used still bundles it.
Frequently Asked Questions
Does This Fix Work on Linux and macOS, or Only on Windows?
The root cause — setuptools v82+ removing pkg_resources — is platform-agnostic and affects Linux and macOS installs equally. On Linux/macOS, instead of editing webui-user.bat, set the environment variable in your shell session before launching:
export PIP_CONSTRAINT=pip-constraints.txt
./webui.sh
The pip-constraints.txt file content and the venv deletion step are identical across all platforms.
Will Pinning setuptools Below v82 Break Any A1111 Extensions or Features?
No. In my testing across a range of popular extensions — ControlNet, ADetailer, Regional Prompter, and several LoRA tools — setuptools versions in the v69–v74 range are fully compatible. The cap only prevents pip from auto-upgrading to a version that strips pkg_resources. None of the A1111 extension ecosystem requires features introduced in setuptools v82+.
Why Did This Suddenly Start Happening If I Never Changed Anything?
This is the most common question I get, and the answer is counterintuitive: you don’t have to change anything for a PyPI package to change under you. When you delete your venv for any reason, pip fetches the current latest version of every package from PyPI at that moment. If your venv was originally built before setuptools v82 was published, it was silently protected. Any new install or venv rebuild after the v82 release window will hit this error on an unmodified A1111 setup.
Is There an Official Patch From AUTOMATIC1111 Planned?
As of May 2026, the community-documented workaround via PIP_CONSTRAINT is the confirmed approach. AUTOMATIC1111 GitHub Discussion #17375. A permanent fix requires either OpenAI updating the CLIP package to remove its pkg_resources import, or A1111’s own launch.py adding native setuptools pinning before pip runs. Neither has been merged into the main branch as of this writing.
What If I See This Error in ComfyUI, Forge, or Another A1111 Fork?
The same pip-constraints.txt + PIP_CONSTRAINT approach applies to any fork that uses pip’s build isolation and depends on CLIP or other legacy packages that import pkg_resources at build time.
- ComfyUI: Create
pip-constraints.txtin the ComfyUI root directory and setPIP_CONSTRAINTbefore runningrun_nvidia_gpu.bator equivalent - Forge/reForge: Same pattern — edit the fork’s equivalent
.batlauncher file - StabilityMatrix-managed installs: Set the constraint in the launch arguments for the specific package environment
Does This Affect Google Colab or Cloud-Based A1111 Setups?
Cloud notebook environments typically pin their own package versions and are less affected. However, if you’re using a self-managed Colab or Paperspace notebook that calls webui.sh with build isolation enabled, the same PIP_CONSTRAINT export approach applies. Add !export PIP_CONSTRAINT=pip-constraints.txt as a notebook cell before the launch cell.
For a broader reference on local AI tool installation errors across the full stack, see the complete guide to A1111 troubleshooting at AIQnAHub — it covers environment, VRAM, extension conflicts, and dependency errors in a single reference.
Leave a Reply