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:
-
Initial Tesseract Issues (Abandoned): I originally tried pytesseract, but Tesseract was a nightmare to configure. I switched to easyocr to avoid that mess.
-
easyocr Installation: I used
pip install easyocr. This should have installed all dependencies, including PyTorch. -
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, andeasyocrbased on Stack Overflow suggestions. No luck.
- Tried
-
Environment Variable Voodoo:
- Verified
TESSDATA_PREFIXis irrelevant (since I’m not using Tesseract anymore). - Double, triple, quadruple-checked my
PATHenvironment variable. It should include:C:\Users\Mohammad\AppData\Local\Programs\Python\Python313C:\Users\Mohammad\AppData\Local\Programs\Python\Python313\Scripts
- Made sure those paths are at the top of the
PATHlist (or at least before any other Python installations). - IMPORTANT NOTE:
where pythonreturns nothing, which is a huge red flag!
- Verified
-
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
ModuleNotFoundErrorstill happens.
- Used the full path to my Python 3.13 executable:
-
site-packages Inspection:
- Looked in
C:\Users\Mohammad\AppData\Local\Programs\Python\Python313\Lib\site-packagesfor conflictingtorchinstallations or weird files. Didn’t find anything obvious.
- Looked in
-
Reinstalling Everything: Uninstalling and reinstalling
easyocrandtorchmultiple 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
torchmodule 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:
ModuleNotFoundErrorpersists, no matter what I try.- Python interpreter is reachable (with the full path).
where pythonreturns 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!