uv: Access denied for `uv pip sync` on Windows

Within a given venv, running uv pip sync <requirement file> fails with Access is denied. This is on Windows.

(venv311) C:\Users\kraken>uv pip sync requirements.txt
error: failed to remove file `\\?\C:\Users\kraken\venv311\Scripts\uv.exe`
  Caused by: Access is denied. (os error 5)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 4
  • Comments: 19 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Yeah, in general you can “solve” this by installing uv outside of whatever environment you’re trying to manage. uv doesn’t need to be in a given virtual environment in order to operate on it (it’s just a Rust binary, it can run over any environment or Python interpreter on your system).

(Of course I’d prefer not to error here though.)

@zanieb We have issues on windows with the path and installing uv globally is not always possible. Also if there is a uv installed inside the env, it will take priority over the one outside since the command will be replaced on env activation.

You cannot run uv self update if uv was installed in the env as package. BTW, it makes way more sense to version control uv this way – also version lock it

I would strongly recommend against managing uv as a Python package and use our installer and uv self update instead.

We use a library called self-replace when targeting the currently-running binary.

Not a solution, but a workaround (and note I use uv within a conda environment). I hit this error when I installed uv within a virtual environment, but when I installed it in my base conda environment, so I could then use it in every created virtual environment, I stopped getting the error.

When I tried updating uv (or pip/setuptools) within the environment, that didn’t help.

I know this won’t help all users, but maybe the handful who stumble in here searching for the Caused by: Access is denied. (os error 5) that use conda. 🤷

I think deleting executable is not allowed when it’s running, but it can rename itself. I think solution here is to rename self to temp dir.