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

Kirn_anat: <p>Hello guys,</p>
<p>I’m pulling my hair out trying to get easyocr working with Python 3.13 on Windows 11. I keep getting the dreaded <code>ModuleNotFoundError: No module named 'torch.backends'</code> error, even though everything <em>seems</em> to be installed correctly. I’ve spent days on this, and I’m at a complete loss.</p>
<p><strong>The Core Problem:</strong></p>
<p>I’m trying to use easyocr, which depends on PyTorch (torch).  My script fails with the <code>ModuleNotFoundError</code>, meaning easyocr can’t find the <code>torch.backends</code> module. This happens <em>despite</em> pip showing all required packages (easyocr, torch, torchvision) as installed.  The problem seems specific to my main Python 3.13 installation.</p>
<p><strong>What I’ve Tried (A LOT):</strong></p>
<p>I’ve tried a ton of things, so I’ll try to keep this organized:</p>
<ol>
<li>
<p><strong>Initial Tesseract Issues (Abandoned):</strong>  I originally tried pytesseract, but Tesseract was a nightmare to configure. I switched to easyocr to avoid that mess.</p>
</li>
<li>
<p><strong>easyocr Installation:</strong>  I used <code>pip install easyocr</code>. This <em>should</em> have installed all dependencies, including PyTorch.</p>
</li>
<li>
<p><strong>PyTorch Shenanigans:</strong></p>
<ul>
<li>Tried <code>pip install torch</code> (CPU version).  pip says it’s already installed.</li>
<li>Checked <code>import torch; print(torch.__version__)</code> - PyTorch <em>seems</em> to be installed.</li>
<li>Even tried specific, compatible versions of <code>torch</code>, <code>torchvision</code>, and <code>easyocr</code> based on Stack Overflow suggestions. No luck.</li>
</ul>
</li>
<li>
<p><strong>Environment Variable Voodoo:</strong></p>
<ul>
<li>Verified <code>TESSDATA_PREFIX</code> is irrelevant (since I’m not using Tesseract anymore).</li>
<li>Double, triple, quadruple-checked my <code>PATH</code> environment variable.  It <em>should</em> include:
<ul>
<li><code>C:\Users\Mohammad\AppData\Local\Programs\Python\Python313</code></li>
<li><code>C:\Users\Mohammad\AppData\Local\Programs\Python\Python313\Scripts</code></li>
</ul>
</li>
<li>Made sure those paths are at the top of the <code>PATH</code> list (or at least before any other Python installations).</li>
<li><strong>IMPORTANT NOTE:</strong>  <code>where python</code> returns <em>nothing</em>, which is a huge red flag!</li>
</ul>
</li>
<li>
<p><strong>Interpreter Checks:</strong></p>
<ul>
<li>Used the full path to my Python 3.13 executable: <code>&amp; "C:\Users\Mohammad\AppData\Local\Programs\Python\Python313\python.exe" "F:\..."</code></li>
<li>This lets the script <em>start</em>, but the <code>ModuleNotFoundError</code> still happens.</li>
</ul>
</li>
<li>
<p><strong>site-packages Inspection:</strong></p>
<ul>
<li>Looked in <code>C:\Users\Mohammad\AppData\Local\Programs\Python\Python313\Lib\site-packages</code> for conflicting <code>torch</code> installations or weird files.  Didn’t find anything obvious.</li>
</ul>
</li>
<li>
<p><strong>Reinstalling Everything:</strong> Uninstalling and reinstalling <code>easyocr</code> and <code>torch</code> multiple times.  No change.</p>
</li>
</ol>
<p><strong>What I HAVEN’T Done (Yet - and this is probably crucial):</strong></p>
<ul>
<li><strong>Portable Python Test:</strong> 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.</li>
<li><strong>Check module __file__ attributes:</strong> I haven’t definitively figured out which specific <code>torch</code> module Python is <em>actually</em> trying to load. I should run this inside the Python 3.13 interpreter (using the full path):</li>
</ul>
<pre><code>```python
import easyocr
print(easyocr.__file__)
import torch
print(torch.__file__)
```
</code></pre>
<p><strong>Summary of the Situation:</strong></p>
<ul>
<li><code>ModuleNotFoundError</code> persists, no matter what I try.</li>
<li>Python interpreter is reachable (with the full path).</li>
<li><code>where python</code> returns nothing - major PATH issue.</li>
<li>Haven’t ruled out conflicting packages or a corrupted PyTorch installation within my main Python 3.13.</li>
<li>haven’t ruled out that it is a system wide problem</li>
</ul>
<p>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.</p>
<p><strong>TL;DR:</strong>  <code>ModuleNotFoundError: No module named 'torch.backends'</code> 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 <code>__file__</code> attributes yet.  Help!</p>
<hr>

ptrblck: <p>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.<br>
I.e. I would create a new and empty virtual environment (via <code>conda</code> or any other package manager you are using) and just <code>pip install</code> 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:</p>
<pre data-code-wrap="python"><code class="lang-python">import torch
print(torch.__version__)
print(torch.__path__)
print(torch.backends)
print(torch.cuda.is_available()) # if you are using a GPU
</code></pre>
<p>if this works fine, you could try to install other applications afterwards hoping these will recognize an already properly installed PyTorch.</p>