Free | No tracking | Every fact with a source|German and English

Error / Installation

ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied – pip cannot modify a file

pip cannot delete or overwrite a file because it is currently in use or you do not have permission.

The message

ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'c:\python39\scripts\pip.exe' Consider using the `--user` option or check the permissions. (deutsch: Zugriff verweigert)

Affects: Python, ComfyUI, AUTOMATIC1111 Stable Diffusion WebUI, Stable Diffusion WebUI Forge, TextGen (text-generation-webui)

Why is this happening?

Windows locks program files while they are running. If you run pip install --upgrade pip directly through pip.exe, pip tries to delete that same running file. Another common reason: Python is in a folder where you do not have write permission without administrator rights. If an AI program is still running, its packages are locked too.

How to fix it

  1. Close all windows where the program or Python is still running (for example, the ComfyUI or WebUI console).
  2. Run pip through Python instead of directly: python -m pip install --upgrade pip (on Windows also py -m pip install --upgrade pip). For portable ComfyUI: .\python_embeded\python.exe -m pip install --upgrade pip.
  3. If Python is in a protected folder (for example C:\Program Files or C:\Python39 for all users), open the terminal with right-click "Run as administrator" and repeat the command.
  4. Alternatively, the message itself suggests the --user option, which installs pip in your user folder: python -m pip install --user paketname.
  5. If pip is then missing altogether ("No module named pip"), restore it with python -m ensurepip --upgrade.
  6. In the long run, it is easier to install Python in a folder where you have write permission without administrator rights.

Set up from scratch again

If it still doesn’t work after that, a fresh setup step by step often helps:

Terms for this

Similar errors

Sources

Checked on Oct 27, 2026. Didn't help? Ask in the forum and name the graphics card, program, and the full message.