WinError 126 when import torch

Normally, this error means that one or more dependent DLL is missing during the initialization, which mostly caused by users that tend to load the CUDA variant of PyTorch on a CPU-only agent. But apparently, your problem is a bit different.

Update:
From the location of your python executable, it seems that you are using the Python distribution from the Microsoft Store. We didn’t test our binaries under this case so there may be some problem. Would you please provide a detailed version of the log using the steps below?

  1. Install Debugging Tools on Windows https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/#install-debugging-tools-for-windows
  2. Run the following code in CMD
    # Turn on loader snaps
    gflags /i python.exe +sls
    # Debug loading torch
    cdb -o -c "~*g; q" python -c "import torch"
    # Turn off loader snaps
    gflags /i python.exe +sls