ModuleNotFoundError: No module named 'torch.backends' with easyocr and Python 3.13 (Windows 11) - Exhaustive Troubleshooting, Still Stuck!

Hello guys,

I’m pulling my hair out trying to get easyocr working with Python 3.13 on Windows 11. I keep getting the dreaded ModuleNotFoundError: No module named 'torch.backends' error, even though everything seems to be installed correctly. I’ve spent days on this, and I’m at a complete loss.

The Core Problem:

I’m trying to use easyocr, which depends on PyTorch (torch). My script fails with the ModuleNotFoundError, meaning easyocr can’t find the torch.backends module. This happens despite pip showing all required packages (easyocr, torch, torchvision) as installed. The problem seems specific to my main Python 3.13 installation.

What I’ve Tried (A LOT):

I’ve tried a ton of things, so I’ll try to keep this organized:

  1. Initial Tesseract Issues (Abandoned): I originally tried pytesseract, but Tesseract was a nightmare to configure. I switched to easyocr to avoid that mess.

  2. easyocr Installation: I used pip install easyocr. This should have installed all dependencies, including PyTorch.

  3. PyTorch Shenanigans:

    • Tried pip install torch (CPU version). pip says it’s already installed.
    • Checked import torch; print(torch.__version__) - PyTorch seems to be installed.
    • Even tried specific, compatible versions of torch, torchvision, and easyocr based on Stack Overflow suggestions. No luck.
  4. Environment Variable Voodoo:

    • Verified TESSDATA_PREFIX is irrelevant (since I’m not using Tesseract anymore).
    • Double, triple, quadruple-checked my PATH environment variable. It should include:
      • C:\Users\Mohammad\AppData\Local\Programs\Python\Python313
      • C:\Users\Mohammad\AppData\Local\Programs\Python\Python313\Scripts
    • Made sure those paths are at the top of the PATH list (or at least before any other Python installations).
    • IMPORTANT NOTE: where python returns nothing, which is a huge red flag!
  5. Interpreter Checks:

    • Used the full path to my Python 3.13 executable: & "C:\Users\Mohammad\AppData\Local\Programs\Python\Python313\python.exe" "F:\..."
    • This lets the script start, but the ModuleNotFoundError still happens.
  6. site-packages Inspection:

    • Looked in C:\Users\Mohammad\AppData\Local\Programs\Python\Python313\Lib\site-packages for conflicting torch installations or weird files. Didn’t find anything obvious.
  7. Reinstalling Everything: Uninstalling and reinstalling easyocr and torch multiple times. No change.

What I HAVEN’T Done (Yet - and this is probably crucial):

  • Portable Python Test: I haven’t yet tested with a portable Python installation to isolate whether the issue is system-wide or specific to my main Python 3.13 install. This is probably my next step.
  • Check module __file__ attributes: I haven’t definitively figured out which specific torch module Python is actually trying to load. I should run this inside the Python 3.13 interpreter (using the full path):
```python
import easyocr
print(easyocr.__file__)
import torch
print(torch.__file__)
```

Summary of the Situation:

  • ModuleNotFoundError persists, no matter what I try.
  • Python interpreter is reachable (with the full path).
  • where python returns nothing - major PATH issue.
  • Haven’t ruled out conflicting packages or a corrupted PyTorch installation within my main Python 3.13.
  • haven’t ruled out that it is a system wide problem

I’m really hoping someone has seen this before or has some fresh ideas. I’m desperate! Any help would be massively appreciated. I feel like I’m missing something obvious.

TL;DR: ModuleNotFoundError: No module named 'torch.backends' with easyocr and Python 3.13 on Windows 11, despite extensive troubleshooting (PATH, versions, reinstalls, etc.). Haven’t done a portable Python test or checked __file__ attributes yet. Help!


I’m not using Windows so won’t know details and common pitfalls, but I would probably start with a quick standalone check making sure PyTorch itself can be used.
I.e. I would create a new and empty virtual environment (via conda or any other package manager you are using) and just pip install the desired PyTorch version you want (without any other applications or libs which are supposed to download and install PyTorch). Once this is done, run a small check via:

import torch
print(torch.__version__)
print(torch.__path__)
print(torch.backends)
print(torch.cuda.is_available()) # if you are using a GPU

if this works fine, you could try to install other applications afterwards hoping these will recognize an already properly installed PyTorch.