Fixing the "Access Denied" (davey.pyd) Error During Hermes Desktop Installer Setup on Windows

Fixing the "Access Denied" (davey.pyd) Error During Hermes Desktop Installer Setup on Windows


If you’ve tried installing or updating the Hermes AI Agent desktop application on Windows, you might have run into a frustrating installer halt. The setup window suddenly stops and throws a red error banner saying:

INSTALL DIDN’T FINISH
Cannot remove item C:\Users\\AppData\Local\hermes\hermes-agent\venv\Lib\site-packages\davey\davey.cp311-win_amd64.pyd: Access to the path 'davey.cp311-win_amd64.pyd' is denied.

This error blocks the installer from completing, leaving you unable to open or use the agent. In this article, we’ll dive into the root cause of this file lock issue on Windows, explain why the installer got stuck, and show how we solved it both for your current setup and permanently in the installer code.


The Root Cause: Windows File Locking & Background Processes

Unlike Linux or macOS—which allow you to delete or replace files even if they are currently opened by active programs—Windows strictly enforces file locking.

If a file (especially executable code like python.exe or compiled C extensions like DLLs and .pyd files) is currently loaded into memory by any running process, Windows denies any attempt to delete, rename, or overwrite it. Doing so throws a native Access is denied (System Error Code 5) exception.

Why does this happen during the Hermes installation?

During an update or reinstall, the Hermes Setup wizard attempts to refresh or recreate the Python virtual environment (venv) directory:

  1. The installer checks if venv exists.
  2. If it does, it tries to delete it using Remove-Item -Recurse -Force "venv" so it can install a clean set of dependencies.
  3. However, if a background agent process (running as pythonw.exe or python.exe from that virtual environment) is still active in the background, Windows locks python.exe and any loaded C extensions—such as davey.cp311-win_amd64.pyd (a native module used by Hermes).
  4. The deletion fails midway, halting the installer with the Access Denied message.

Why the Initial Installer Cleanup Failed

The Hermes installer did have a process-cleanup mechanism in its PowerShell script (install.ps1), which looked like this:

if ($env:OS -eq "Windows_NT") {
    $myPid = $PID
    Write-Info "Stopping any running hermes processes before recreating venv..."
    & taskkill /F /T /IM hermes.exe /FI "PID ne $myPid" 2>$null | Out-Null
    Start-Sleep -Milliseconds 800
}

While this successfully terminated hermes.exe (the Electron GUI application), it failed to clean up the underlying background worker processes. When Electron spawns a Python daemon, terminating the main Electron process doesn't always cascade down to kill the children on Windows, leaving a orphan pythonw.exe running and locking the virtual environment.


The Solution

To solve this issue completely, we need to address two things: clearing the lock immediately so you can finish installing, and fixing the installer script so this never happens to users in the future.

1. The Immediate Quick Fix (For the User)

To instantly free the file lock and let the installer finish:

  1. Open Task Manager (Ctrl + Shift + Esc).
  2. Search for any processes named Python or pythonw.exe.
  3. Right-click and select End Task on those processes, particularly any running from AppData\Local\hermes.
  4. Alternatively, run the following command in PowerShell/CMD: cmd taskkill /F /IM pythonw.exe
  5. Go back to the Hermes Setup screen and click "Retry install". The installation will now succeed.

2. The Permanent Fix (In the Installer Code)

We updated the installation script (install.ps1) to target and terminate any running Python interpreters specifically tied to the virtual environment we are about to destroy.

Here is the enhanced cleanup logic added before the venv directory deletion:

if ($env:OS -eq "Windows_NT") {
    $myPid = $PID
    Write-Info "Stopping any running hermes processes before recreating venv..."
    & taskkill /F /T /IM hermes.exe /FI "PID ne $myPid" 2>$null | Out-Null

    # Also stop any running python/pythonw processes using the virtual environment
    $venvPath = Join-Path $InstallDir "venv"
    Get-Process -Name "python", "pythonw" -ErrorAction SilentlyContinue | Where-Object {
        try {
            $_.Path -and $_.Path.StartsWith("$venvPath\", [System.StringComparison]::OrdinalIgnoreCase)
        } catch {
            $false
        }
    } | ForEach-Object {
        Write-Info "Stopping running venv process: $($_.Name) (PID $($_.Id))"
        Stop-Process -Id $_.Id -Force -ErrorAction SilentlyContinue
    }
    Start-Sleep -Milliseconds 800
}

Why this code works:

  • It targets processes named python and pythonw.
  • It uses $_.Path.StartsWith to target only the processes running out of the specific virtual environment folder (venv/) for Hermes. This avoids accidentally killing a user's other active Python scripts or development environments.
  • It uses a try/catch block to handle cases where accessing the path of system-protected processes throws permission errors.
  • It calls Stop-Process -Force to cleanly terminate the running instances before calling Remove-Item on the folder.

Summary

Windows file locks are a common headache for installer developers, but they can be easily managed by ensuring that any background daemons or workers are correctly cleaned up. By targeting virtual-environment-specific python processes during setup, Hermes updates are now robust, silent, and error-free on Windows machines.

Teknoding Fathurrahman is a writer and blogger at Teknoding.com. He has written many articles about technology for 5 years. Fathurrahman is driven by a desire to help others understand technology. He makes complex concepts easy to understand, making technology accessible to a wider audience. His articles are engaging narratives that help readers understand the digital world. Fathurrahman is also an active member of the tech community, sharing knowledge and insights with other enthusiasts and experts.

Post a Comment for "Fixing the "Access Denied" (davey.pyd) Error During Hermes Desktop Installer Setup on Windows"

PIPPIT CAPCUT AI Create Free AI VEO 3.1/SORA 2 Unlimited Videos, Text & Avatars — Nano Banana 🍌

Use CapCut Creator to design videos, images, and avatars with AI — all for free.

Start Creating Now