Unable to import torch in pyinstaller .exe file in Windows

Hi, I want to create .exe file using pyinstaller.
My code starts with:

import torch

After creating .exe file with the following command:

pyinstaller --onefile cli.py --additional-hooks-dir \path\to\my\venv\site-packages

I encounter the following error:

Traceback (most recent call last):
  File "cli_draft.py", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
  File "torch\__init__.py", line 137, in <module>
OSError: [WinError 126] The specified module could not be found. Error loading "C:\Users\User\AppData\Local\Temp\_MEI113522\torch\lib\caffe2_nvrtc.dll" or one of its dependencies.
[8760] Failed to execute script 'cli_draft' due to unhandled exception!

I’m working in a conda virtual environment with pytorch==1.11.0 cudatoolkit==11.3.1 versions.

I also tried to create .exe file in pytorch==1.11.0 cudatoolkit==10.2 environment and it worked. Also it works when I activate my virtual environment before running the .exe file. But I want to run it without activation.

My conda environment is:

name: venv_4
channels:
  - pytorch
  - conda-forge
  - anaconda
  - defaults
dependencies:
  - altgraph=0.17.3=py38haa95532_0
  - appdirs=1.4.4=pyhd3eb1b0_0
  - blas=1.0=mkl
  - bottleneck=1.3.5=py38h080aedc_0
  - brotli=1.0.9=h2bbff1b_7
  - brotli-bin=1.0.9=h2bbff1b_7
  - brotlipy=0.7.0=py38h2bbff1b_1003
  - bzip2=1.0.8=he774522_0
  - ca-certificates=2023.01.10=haa95532_0
  - certifi=2022.12.7=py38haa95532_0
  - cffi=1.15.1=py38h2bbff1b_3
  - charset-normalizer=2.0.4=pyhd3eb1b0_0
  - colorama=0.4.6=py38haa95532_0
  - cryptography=38.0.4=py38h21b164f_0
  - cudatoolkit=11.3.1=h59b6b97_2
  - cycler=0.11.0=pyhd3eb1b0_0
  - fftw=3.3.9=h2bbff1b_1
  - flit-core=3.6.0=pyhd3eb1b0_0
  - fonttools=4.25.0=pyhd3eb1b0_0
  - freeglut=3.2.2=h63175ca_2
  - freetype=2.12.1=ha860e81_0
  - future=0.18.2=py38_1
  - gettext=0.21.1=h5728263_0
  - gst-plugins-base=1.20.2=he07aa86_2
  - gstreamer=1.20.2=hdff456e_1
  - icc_rt=2022.1.0=h6049295_2
  - icu=70.1=h0e60522_0
  - idna=3.4=py38haa95532_0
  - intel-openmp=2021.4.0=haa95532_3556
  - jasper=2.0.33=hc2e4405_1
  - jpeg=9e=h2bbff1b_0
  - kiwisolver=1.4.4=py38hd77b12b_0
  - krb5=1.19.4=h5b6d351_0
  - lerc=3.0=hd77b12b_0
  - libblas=3.9.0=12_win64_mkl
  - libbrotlicommon=1.0.9=h2bbff1b_7
  - libbrotlidec=1.0.9=h2bbff1b_7
  - libbrotlienc=1.0.9=h2bbff1b_7
  - libcblas=3.9.0=12_win64_mkl
  - libclang=14.0.6=default_hf4acfee_0
  - libclang13=14.0.6=default_h8992b79_0
  - libdeflate=1.8=h2bbff1b_5
  - libffi=3.4.2=hd77b12b_6
  - libglib=2.74.1=h79619a9_0
  - libiconv=1.17=h8ffe710_0
  - liblapack=3.9.0=12_win64_mkl
  - liblapacke=3.9.0=12_win64_mkl
  - libogg=1.3.5=h2bbff1b_1
  - libopencv=4.5.5=py38h3d2d820_13
  - libpng=1.6.37=h2a8f88b_0
  - libprotobuf=3.20.3=h23ce68f_0
  - libtiff=4.4.0=h8a3f274_2
  - libuv=1.40.0=he774522_0
  - libvorbis=1.3.7=he774522_0
  - libwebp=1.2.4=h2bbff1b_0
  - libwebp-base=1.2.4=h2bbff1b_0
  - libzlib=1.2.13=hcfcfb64_4
  - lz4-c=1.9.4=h2bbff1b_0
  - macholib=1.16.2=py38haa95532_0
  - matplotlib=3.5.3=py38haa95532_0
  - matplotlib-base=3.5.3=py38hd77b12b_0
  - mkl=2021.4.0=h0e2418a_729
  - mkl-service=2.4.0=py38h2bbff1b_0
  - munkres=1.1.4=py_0
  - natsort=8.2.0=pyhd8ed1ab_0
  - numexpr=2.8.4=py38h5b0cc5e_0
  - numpy=1.23.2=py38h223ccf5_0
  - opencv=4.5.5=py38haa244fe_13
  - openssl=1.1.1s=h2bbff1b_0
  - packaging=22.0=py38haa95532_0
  - pandas=1.4.3=py38hd77b12b_0
  - pcre2=10.37=h0ff8eda_1
  - pefile=2022.5.30=py38haa95532_0
  - pillow=9.3.0=py38hdc2b20a_1
  - pip=22.3.1=py38haa95532_0
  - ply=3.11=py38_0
  - pooch=1.4.0=pyhd3eb1b0_0
  - py-opencv=4.5.5=py38h4317176_13
  - pycparser=2.21=pyhd3eb1b0_0
  - pyinstaller=5.8.0=py38ha959d8a_0
  - pyinstaller-hooks-contrib=2022.14=py38haa95532_0
  - pyopenssl=22.0.0=pyhd3eb1b0_0
  - pyparsing=3.0.9=py38haa95532_0
  - pyqt=5.15.7=py38h75e37d8_0
  - pyqt5-sip=12.11.0=py38h885f38d_0
  - pysocks=1.7.1=py38haa95532_0
  - python=3.8.10=hdbf39b2_7
  - python-dateutil=2.8.2=pyhd3eb1b0_0
  - python_abi=3.8=2_cp38
  - pytorch=1.11.0=py3.8_cuda11.3_cudnn8_0
  - pytorch-mutex=1.0=cuda
  - pytz=2022.7=py38haa95532_0
  - pywin32=305=py38h2bbff1b_0
  - pywin32-ctypes=0.2.0=py38_1000
  - pyyaml=6.0=py38h2bbff1b_1
  - qt-main=5.15.4=h467ea89_2
  - requests=2.28.1=py38haa95532_0
  - scipy=1.10.0=py38h321e85e_0
  - seaborn=0.11.2=pyhd3eb1b0_0
  - setuptools=65.6.3=py38haa95532_0
  - sip=6.6.2=py38hd77b12b_0
  - six=1.16.0=pyhd3eb1b0_1
  - sqlite=3.40.1=h2bbff1b_0
  - tbb=2021.6.0=h59b6b97_1
  - tk=8.6.7=vc14hb68737d_1
  - toml=0.10.2=pyhd3eb1b0_0
  - torchaudio=0.11.0=py38_cu113
  - torchvision=0.12.0=py38_cu113
  - tornado=6.2=py38h2bbff1b_0
  - tqdm=4.64.0=py38haa95532_0
  - typing_extensions=4.4.0=py38haa95532_0
  - ucrt=10.0.20348.0=haa95532_0
  - urllib3=1.26.14=py38haa95532_0
  - vc=14.2=h21ff451_1
  - vc14_runtime=14.34.31931=h5081d32_16
  - vs2015_runtime=14.34.31931=hed1258a_16
  - wheel=0.37.1=pyhd3eb1b0_0
  - win_inet_pton=1.1.0=py38haa95532_0
  - wincertstore=0.2=py38haa95532_2
  - xz=5.2.10=h8cc25b3_1
  - yaml=0.2.5=he774522_0
  - zlib=1.2.13=hcfcfb64_4
  - zstd=1.5.2=h19a0ad4_0
prefix: C:\Users\User\anaconda3\envs\venv_4

To reproduce the issue you can create conda venv with provided package versions and create .py file that contains only the following line:

import torch

I also provide .exe file creation logs:

890 INFO: PyInstaller: 5.8.0
890 INFO: Python: 3.8.10 (conda)
900 INFO: Platform: Windows-10-10.0.19045-SP0
900 INFO: wrote C:\Users\User\Desktop\ml\JNJEL\ml\ml_necessary_3\cli_draft.spec
901 INFO: UPX is not available.
906 INFO: Extending PYTHONPATH with paths
['C:\\Users\\User\\Desktop\\ml\\JNJEL\\ml\\ml_necessary_3']
1285 INFO: checking Analysis
1446 INFO: Building because hookspath changed
1446 INFO: Initializing module dependency graph...
1450 INFO: Caching module graph hooks...
1456 WARNING: Several hooks defined for module 'numpy'. Please take care they do not conflict.
1464 INFO: Analyzing base_library.zip ...
4668 INFO: Loading module hook 'hook-heapq.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
4875 INFO: Loading module hook 'hook-encodings.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
6473 INFO: Loading module hook 'hook-pickle.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
7205 INFO: Caching module dependency graph...
7295 INFO: running Analysis Analysis-00.toc
7307 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by C:\Users\User\anaconda3\envs\venv_4\python.exe
7471 INFO: Analyzing C:\Users\User\Desktop\ml\JNJEL\ml\ml_necessary_3\cli_draft.py
7498 INFO: Loading module hook 'hook-torch.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
7842 INFO: Loading module hook 'hook-platform.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
7967 INFO: Loading module hook 'hook-pkg_resources.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
10452 INFO: Loading module hook 'hook-xml.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
10485 INFO: Loading module hook 'hook-sysconfig.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
10715 INFO: Loading module hook 'hook-numpy.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\Lib\\site-packages\\numpy\\_pyinstaller'...
11074 INFO: Loading module hook 'hook-numpy._pytesttester.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
11412 INFO: Loading module hook 'hook-multiprocessing.util.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
11898 INFO: Loading module hook 'hook-difflib.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
13045 INFO: Loading module hook 'hook-sqlite3.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
16383 INFO: Loading module hook 'hook-pandas.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
920 INFO: Note: NumExpr detected 12 cores but "NUMEXPR_MAX_THREADS" not set, so enforcing safe limit of 8.
921 INFO: NumExpr defaulting to 8 threads.
18410 INFO: Loading module hook 'hook-pytz.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
18823 INFO: Loading module hook 'hook-scipy.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
18947 INFO: Loading module hook 'hook-pycparser.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
19271 INFO: Processing pre-find module path hook distutils from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
19601 INFO: Loading module hook 'hook-distutils.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
19686 INFO: Loading module hook 'hook-distutils.util.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
19797 INFO: Loading module hook 'hook-setuptools.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
22595 INFO: Loading module hook 'hook-packaging.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
23368 INFO: Loading module hook 'hook-scipy.sparse.csgraph.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
23517 INFO: Loading module hook 'hook-scipy.linalg.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
24697 INFO: Loading module hook 'hook-matplotlib.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
25036 INFO: Processing pre-safe import module hook gi from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-gi.py'.
25100 INFO: Loading module hook 'hook-PIL.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
25211 INFO: Loading module hook 'hook-PIL.Image.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
26433 INFO: Loading module hook 'hook-PIL.ImageFilter.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
27434 INFO: Loading module hook 'hook-matplotlib.backends.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
27692 INFO: Processing pre-safe import module hook six.moves from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-six.moves.py'.
29159 INFO: Loading module hook 'hook-certifi.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
29213 INFO: Loading module hook 'hook-scipy.spatial.transform.rotation.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
31130 INFO: Loading module hook 'hook-pandas.io.formats.style.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
33463 INFO: Loading module hook 'hook-PyQt5.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
34000 INFO: Loading module hook 'hook-pandas.plotting.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
34092 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
34115 INFO: Loading module hook 'hook-xml.dom.domreg.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
35248 INFO: Processing pre-safe import module hook urllib3.packages.six.moves from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-urllib3.packages.six.moves.py'.
35895 INFO: Loading module hook 'hook-cryptography.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
38723 INFO: Loading module hook 'hook-scipy.io.matlab.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
39218 INFO: Loading module hook 'hook-torchvision.ops.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
40377 INFO: Processing module hooks...
40401 INFO: Loading module hook 'hook-matplotlib.backends.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
40402 INFO: Matplotlib backend selection method: automatic discovery of used backends
40624 INFO: Trying determine the default backend as first importable candidate from the list: ['Qt5Agg', 'Gtk3Agg', 'TkAgg', 'WxAgg']
41038 INFO: Selected matplotlib backends: ['Qt5Agg']
41400 INFO: Loading module hook 'hook-PIL.SpiderImagePlugin.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
41450 INFO: Processing pre-safe import module hook win32com from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\pre_safe_import_module\\hook-win32com.py'.
41513 INFO: Loading module hook 'hook-win32com.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
41515 INFO: Loading module hook 'hook-pythoncom.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
41777 INFO: Loading module hook 'hook-pywintypes.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
42522 INFO: Loading module hook 'hook-PyQt5.QtCore.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
42619 INFO: Loading module hook 'hook-PyQt5.QtGui.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
42787 INFO: Loading module hook 'hook-PyQt5.QtWidgets.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
42903 INFO: Loading module hook 'hook-scipy.special._ellip_harm_2.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
42904 INFO: Loading module hook 'hook-scipy.special._ufuncs.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
42905 INFO: Loading module hook 'hook-scipy.stats._stats.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
42923 INFO: Loading module hook 'hook-setuptools.msvc.py' from 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks'...
44097 INFO: Looking for ctypes DLLs
44135 INFO: Analyzing run-time hooks ...
44147 INFO: Including run-time hook 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgutil.py'
44151 INFO: Including run-time hook 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_inspect.py'
44153 INFO: Including run-time hook 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_multiprocessing.py'
44156 INFO: Including run-time hook 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pyqt5.py'
44159 INFO: Including run-time hook 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgres.py'
44163 INFO: Including run-time hook 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_win32comgenpy.py'
44164 INFO: Including run-time hook 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\rthooks\\pyi_rth_pywintypes.py'
44166 INFO: Including run-time hook 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\rthooks\\pyi_rth_pythoncom.py'
44168 INFO: Including run-time hook 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_setuptools.py'
44169 INFO: Including run-time hook 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_mplconfig.py'
44288 INFO: Looking for dynamic libraries
1417 INFO: Note: NumExpr detected 12 cores but "NUMEXPR_MAX_THREADS" not set, so enforcing safe limit of 8.
1417 INFO: NumExpr defaulting to 8 threads.
C:\Users\User\anaconda3\envs\venv_4\lib\site-packages\PyInstaller\building\build_main.py:175: UserWarning: The numpy.array_api submodule is still experimental. See NEP 47.
  __import__(package)
C:\Users\User\anaconda3\envs\venv_4\lib\site-packages\torchaudio\backend\utils.py:66: UserWarning: No audio backend is available.
  warnings.warn("No audio backend is available.")
2911 INFO: Extra DLL search directories (AddDllDirectory): ['C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\torch\\lib', 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\Library\\bin', 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\torchvision', 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\torchvision', 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\torchvision', 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\torchvision']
2911 INFO: Extra DLL search directories (PATH): ['C:\\Users\\User\\anaconda3\\envs\\venv_4', 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\Library\\mingw-w64\\bin', 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\Library\\usr\\bin', 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\Library\\bin', 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\Scripts', 'C:\\Users\\User\\anaconda3\\envs\\venv_4\\bin', 'C:\\Users\\User\\anaconda3\\condabin', 'C:\\Windows\\system32', 'C:\\Windows', 'C:\\Windows\\System32\\Wbem', 'C:\\Windows\\System32\\WindowsPowerShell\\v1.0', 'C:\\Windows\\System32\\OpenSSH', 'C:\\Users\\User\\AppData\\Local\\Programs\\Python\\Python38\\Scripts', 'C:\\Users\\User\\AppData\\Local\\Programs\\Python\\Python38', 'C:\\Users\\User\\AppData\\Local\\Programs\\Python\\Launcher', 'C:\\Users\\User\\AppData\\Local\\Microsoft\\WindowsApps', '.']
49515 INFO: Looking for eggs
49515 INFO: Using Python library C:\Users\User\anaconda3\envs\venv_4\python38.dll
49516 INFO: Found binding redirects:
[]
49534 INFO: Warnings written to C:\Users\User\Desktop\ml\JNJEL\ml\ml_necessary_3\build\cli_draft\warn-cli_draft.txt
49753 INFO: Graph cross-reference written to C:\Users\User\Desktop\ml\JNJEL\ml\ml_necessary_3\build\cli_draft\xref-cli_draft.html
49945 INFO: Appending 'datas' from .spec
49953 INFO: checking PYZ
49980 INFO: Building because toc changed
49981 INFO: Building PYZ (ZlibArchive) C:\Users\User\Desktop\ml\JNJEL\ml\ml_necessary_3\build\cli_draft\PYZ-00.pyz
52112 INFO: Building PYZ (ZlibArchive) C:\Users\User\Desktop\ml\JNJEL\ml\ml_necessary_3\build\cli_draft\PYZ-00.pyz completed successfully.
52163 INFO: checking PKG
52274 INFO: Building because toc changed
52275 INFO: Building PKG (CArchive) cli_draft.pkg
448307 INFO: Building PKG (CArchive) cli_draft.pkg completed successfully.
448475 INFO: Bootloader C:\Users\User\anaconda3\envs\venv_4\lib\site-packages\PyInstaller\bootloader\Windows-64bit-intel\run.exe
448476 INFO: checking EXE
448595 INFO: Rebuilding EXE-00.toc because cli_draft.exe missing
448596 INFO: Building EXE from EXE-00.toc
448596 INFO: Copying bootloader EXE to C:\Users\User\Desktop\ml\JNJEL\ml\ml_necessary_3\dist\cli_draft.exe.notanexecutable
448631 INFO: Copying icon to EXE
448632 INFO: Copying icons from ['C:\\Users\\User\\anaconda3\\envs\\venv_4\\lib\\site-packages\\PyInstaller\\bootloader\\images\\icon-console.ico']
448651 INFO: Writing RT_GROUP_ICON 0 resource with 104 bytes
448651 INFO: Writing RT_ICON 1 resource with 3752 bytes
448651 INFO: Writing RT_ICON 2 resource with 2216 bytes
448652 INFO: Writing RT_ICON 3 resource with 1384 bytes
448652 INFO: Writing RT_ICON 4 resource with 37019 bytes
448653 INFO: Writing RT_ICON 5 resource with 9640 bytes
448653 INFO: Writing RT_ICON 6 resource with 4264 bytes
448654 INFO: Writing RT_ICON 7 resource with 1128 bytes
448656 INFO: Copying 0 resources to EXE
448656 INFO: Embedding manifest in EXE
448657 INFO: Updating manifest in C:\Users\User\Desktop\ml\JNJEL\ml\ml_necessary_3\dist\cli_draft.exe.notanexecutable
448675 INFO: Updating resource type 24 name 1 language 0
448677 INFO: Appending PKG archive to EXE
449867 INFO: Fixing EXE headers
457495 INFO: Building EXE from EXE-00.toc completed successfully.

Hi,
I am also facing a similar issue right now.
Were you able to find the fix?

Hi, no I haven’t found a solution yet.