There is no pytorch in conda in windows environment

Asked 2 years ago, Updated 2 years ago, 86 views

I try to install pytorch in anaconda environment, but I get an import error no matter how many times I try.
I made a virtual environment with anaconda and burned it, but the results are as follows.

(nn) C:\Users\USER>conda install pytorch torchvision-cpytorch
Collecting package metadata (current_repoda.json): done
Solving environment: done

# All requested packages already installed.


(nn) C:\Users\USER> python-c "import torch;print(torch.__version__)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\USER\anaconda3\envs\nn\lib\site-packages\torch\_init__.py", line 81, in<module>
    ctypes.CDLL(dll)
  File "C:\Users\USER\anaconda3\envs\nn\lib\ctypes\_init__.py", line 364, in_init__
    self._handle=_dlopen(self._name, mode)
OSError: [WinError126] The specified module was not found.

(nn) C:\Users\USER>

I also tried to install the version from the Pythorch page, but the results remained the same.

Please let me know if there is any solution.

Environment
Windows 10
CUDA 10.1
cuDNN v7.6.5
NVIDIA 2019.3 Intel® Core™ i7-8750H [email protected] 2.21GHz 16.0GB NVIDIA is also installed, so I think it's a GPU.

python machine-learning windows-10 anaconda pytorch

2022-09-30 19:21

1 Answers

Try installing it with the following command:

conda install pytorch torchvision cpuonly-cpytorch

The same thing happened in this environment.

> python-c "import torch;print(torch.__version__)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\XXXX\Anaconda3\lib\site-packages\torch\_init__.py", line 81, in<module>
    ctypes.CDLL(dll)
  File "C:\Users\XXXX\Anaconda3\lib\ctypes\_init__.py", line 364, in_init__
    self._handle=_dlopen(self._name, mode)
OSError: [WinError126] The specified module was not found.

I found similar questions and answers in StackOverflow.
After installing the cpu-only package according to John's answer, the problem was resolved.

This is most probably because you are using a CUDA variant of PyTorch on a system that does not' have GPU driver installed. That is to say, if you don't have a Nvidia GPU card, please install the cpu-only package recording to the commands on

On systems that do not have GPU drivers installed, it appears that the cpu-only package must be installed.
Unfortunately, I can't explain the details because I don't know much about GPUs.


2022-09-30 19:21

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.