title: PyInstaller ImportError: DLL load failed: The specified module could not be found. (PyTorch)
body: <p><strong>My code</strong></p>
  <p>My code directory is as below (simplified):</p>
  <pre><code>./__init__.py
  ./maingui.py
  ./sharedData.py
  ./util.py
  ./...
  </code></pre>
  <p>In <code>maingui.py</code> I am importing the following:</p>
  <pre><code>from PyQt5 import QtCore, QtGui, QtWidgets
  import numpy as np 
  import os
  import pathlib
  import copy
  import csv
  from math import *
  import cv2
  from glob import glob
  import pydicom
  from qtrangeslider import QRangeSlider
  from torch import cuda
  
  from sharedData import sharedData
  from util import foo1, foo2
  </code></pre>
  <p>I am going through a lot of importing errors with PyInstaller. But I am trying to debug step by step. The first error occurred while importing <code>cv2</code>. I solved this specific issue by adding <code>--paths=&lt;path to cv2&gt;</code>:</p>
  <pre><code>pyinstaller -w --collect-submodules=pydicom --clean --paths=&quot;&lt;path to venv&gt;\venv_py37_mrigui\lib\site-packages\cv2&quot; maingui.py
  </code></pre>
  <p><strong>Error</strong></p>
  <p>Pyinstaller produced no errors in cmd, but when I <strong>executed the .exe</strong> I got the error:</p>
  <pre><code>Traceback (most recent call last):
  File &quot;mrigui_py37\code\maingui.py&quot;, line 12, in &lt;module&gt;
  File &quot;PyInstaller\loader\pyimod03_importers.py&quot;, line 476, in exec_module
  File &quot;torch\__init__.py&quot;, line 197, in &lt;module&gt;
  ImportError: DLL load failed: The specified module could not be found.
  </code></pre>
  <p><strong>Failed fix attempt</strong></p>
  <p>With the same logic as I fixed the <code>cv2</code> issue, I added <code>--paths=&quot;&lt;path to torch&gt;&quot;</code>:</p>
  <pre><code>pyinstaller -w --collect-submodules=pydicom --clean --paths=&quot;&lt;path to venv&gt;\venv_py37_mrigui\lib\site-packages\cv2&quot; --paths=&quot;&lt;path to venv&gt;\venv_py37_mrigui\lib\site-packages\torch maingui.py
  </code></pre>
  <p>But I got a series of errors in <strong>cmd</strong> such as:</p>
  <pre><code>ImportError: cannot import name 'absolute_import' from '__future__' (C:\Users\vange\Documents\Python Scripts\venvs_forEXE\mrigui_py37_venv\venv_py37_mrigui\lib\site-packages\torch\__future__.py)
  ImportError: cannot import name 'MappingProxyType' from 'types' (C:\Users\vange\Documents\Python Scripts\venvs_forEXE\mrigui_py37_venv\venv_py37_mrigui\lib\site-packages\torch\types.py)
  ImportError: cannot import name 'MappingProxyType' from 'types' (C:\Users\vange\Documents\Python Scripts\venvs_forEXE\mrigui_py37_venv\venv_py37_mrigui\lib\site-packages\torch\types.py)
  [...]
  </code></pre>