ImportError: DLL load failed while importing _C: Das angegebene Modul wurde nicht gefunden./The specified module can not be found

Hi everyone,
Ive just installed torch and torchvision on my anaconda shell:

packages in environment at C:\Users\benja\anaconda3:

Name Version Build Channel

pytorch 2.5.1 py3.11_cpu_0 pytorch
pytorch-mutex 1.0 cpu pytorch

packages in environment at C:\Users\benja\anaconda3:

Name Version Build Channel

torchvision 0.20.1 py311_cpu pytorch

However, when I am trying import torch and torchvision, the following message is displayed:


ImportError Traceback (most recent call last)
Cell In[7], line 3
1 import inspect
2 import torch
----> 3 import torchvision
4 from torch import nn
5 from torch import optim

File ~\anaconda3\Lib\site-packages\torchvision_init_.py:9
5 import torch
7 # Don’t re-order these, we need to load the _C extension (done when importing
8 # .extensions) before entering _meta_registrations.
----> 9 from .extension import _HAS_OPS # usort:skip
10 from torchvision import _meta_registrations, datasets, io, models, ops, transforms, utils # usort:skip
12 try:

File ~\anaconda3\Lib\site-packages\torchvision\extension.py:6
2 import sys
4 import torch
----> 6 from ._internally_replaced_utils import _get_extension_path
9 _HAS_OPS = False
12 def _has_ops():

File ~\anaconda3\Lib\site-packages\torchvision_internally_replaced_utils.py:4
1 import importlib.machinery
2 import os
----> 4 from torch.hub import _get_torch_home
7 _HOME = os.path.join(_get_torch_home(), “datasets”, “vision”)
8 _USE_SHARDED_DATASETS = False

File ~\anaconda3\Lib\site-packages\torch\hub.py:22
19 from urllib.request import Request, urlopen
21 import torch
—> 22 from torch.serialization import MAP_LOCATION
25 class _Faketqdm: # type: ignore[no-redef]
26 def init(self, total=None, disable=False, unit=None, *args, **kwargs):

File ~\anaconda3\Lib\site-packages\torch\serialization.py:35
33 import torch
34 import torch._weights_only_unpickler as _weights_only_unpickler
—> 35 from torch._sources import get_source_lines_and_file
36 from torch._utils import _import_dotted_name
37 from torch.storage import _get_dtype_from_pickle_storage_type

File ~\anaconda3\Lib\site-packages\torch_sources.py:8
5 from textwrap import dedent
6 from typing import Any, List, NamedTuple, Optional, Tuple
----> 8 from torch._C import ErrorReport
9 from torch._C._jit_tree_views import SourceRangeFactory
12 def get_source_lines_and_file(
13 obj: Any,
14 error_msg: Optional[str] = None,
15 ) → Tuple[List[str], int, Optional[str]]:

ImportError: DLL load failed while importing _C: Das angegebene Modul wurde nicht gefunden.

How to solve this issue?

Not reproducible by installing 2.5.1+cpu from conda:

conda install pytorch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 cpuonly -c pytorch
...
The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    brotli-python-1.0.9        |  py311h6a678d5_9         356 KB
    certifi-2025.1.31          |  py311h06a4308_0         163 KB
    filelock-3.13.1            |  py311h06a4308_0          24 KB
    gmpy2-2.2.1                |  py311h5eee18b_0         248 KB
    idna-3.7                   |  py311h06a4308_0         133 KB
    jinja2-3.1.5               |  py311h06a4308_0         358 KB
    markupsafe-3.0.2           |  py311h5eee18b_0          27 KB
    mkl-service-2.4.0          |  py311h5eee18b_2          69 KB
    mkl_fft-1.3.11             |  py311h5eee18b_0         207 KB
    mkl_random-1.2.8           |  py311ha02d727_0         328 KB
    mpmath-1.3.0               |  py311h06a4308_0         1.0 MB
    networkx-3.4.2             |  py311h06a4308_0         3.1 MB
    numpy-2.0.1                |  py311h08b1b3b_1          11 KB
    numpy-base-2.0.1           |  py311hf175353_1         9.1 MB
    pillow-11.1.0              |  py311hcea889d_0         973 KB
    pysocks-1.7.1              |  py311h06a4308_0          35 KB
    pytorch-2.5.1              |     py3.11_cpu_0        92.0 MB  pytorch
    pyyaml-6.0.2               |  py311h5eee18b_0         223 KB
    requests-2.32.3            |  py311h06a4308_1         126 KB
    sympy-1.13.3               |  py311h06a4308_1        15.4 MB
    torchaudio-2.5.1           |        py311_cpu         5.1 MB  pytorch
    torchvision-0.20.1         |        py311_cpu         7.1 MB  pytorch
    typing_extensions-4.12.2   |  py311h06a4308_0          81 KB
    urllib3-2.3.0              |  py311h06a4308_0         241 KB
    ------------------------------------------------------------
                                           Total:       136.4 MB
>>> import torch                                                                                                                                                                                                   
>>> import torchvision
>>> torch.__version__                                                                                                                                                                                              
'2.5.1'                                                                                                                                                                                                            
>>> torchvision.__version__                                                                                                                                                                                        
'0.20.1'     

to clarify, I am working on jupyter with Python 3.11.7. When am trying to import, the kernel dies.