hatch icon indicating copy to clipboard operation
hatch copied to clipboard

hatch command causes: Magic number 'UVSC' or 'UVPY' not found

Open magrosso opened this issue 9 months ago • 2 comments

I keep getting this error when inside the hatch default environment when issuing any hatch command, e.g. "hatch version"

Outside hatch environment, I don't get the error.

Magic number 'UVSC' or 'UVPY' not found at the end of the file. Did you append the magic number, the length and the path to the python executable at the end of the file?

I installed latest hatch on Windows 11 using MSI file.

I already deleted:

  • all other hatch executables except the one in Program Files
  • all pyc files in pycache folders

magrosso avatar Apr 17 '25 07:04 magrosso

I see this error when using powershell5 on windows.

karthiknadig avatar May 09 '25 19:05 karthiknadig

I ran into the same issue when setting up a new Windows 11 24H2 VM. I installed Python 3.11 - 3.13 through WinGet. I then installed Hatch through WinGet with the following command which indirectly uses the GUI installer:

winget install -e --id PyPA.Hatch --scope machine --accept-package-agreements

Strangely, I could run some hatch commands successfully, but if I ran scripts that included hatch commands, I received the above "magic number" error. I tried several things to see if it would fix the problem:

  • Installed uv through WinGet
  • Set the HATCH_ENV_TYPE_VIRTUAL_UV_PATH environment variable to the uv.exe binary.

One thing I noticed is that when I ran Hatch, it would install a Python environment using PyApp.

I then uninstalled and re-installed Hatch using pipx. Hatch no longer installed a PyApp Python environment and the "magic number" errors went away. So ultimately I think this issue has something to do with the PyApp Python environment that Hatch installs.

kmray avatar Jun 03 '25 01:06 kmray