Problems installing and importing pytorch

2.3k Views Asked by At

It's taken me hours trying to install pytorch using an anaconda environment. It appears that I've finally managed it using conda install filename.tar.bz2:

(pytorch) C:\Users\conner\aipND\img_classifier_project>conda list
# packages in environment at C:\Users\conner\Anaconda3\envs\pytorch:
#
blas                      1.1                    openblas    conda-forge
certifi                   2018.4.16                py35_0    conda-forge
cffi                      1.11.5                   py35_0    conda-forge
cmake                     3.11.1                        0    conda-forge
libflang                  5.0.0             vc14_20180208  [vc14]  conda-forge
llvm-meta                 5.0.0                         0    conda-forge
mkl                       2017.0.3                      0
numpy                     1.14.3          py35_blas_openblas_200  [blas_openblas]  conda-forge
openblas                  0.2.20                   vc14_7  [vc14]  conda-forge
openmp                    5.0.0                    vc14_1  [vc14]  conda-forge
pip                       9.0.3                    py35_0    conda-forge
pycparser                 2.18                     py35_0    conda-forge
python                    3.5.1                         1    conda-forge
pytorch                   0.3.1           py35_cuda90_cudnn7he774522_2  [cuda90]  file:///C:/Users/User 1/Downloads
pyyaml                    3.12                     py35_1    conda-forge
setuptools                39.1.0                   py35_0    conda-forge
typing                    3.6.4                    py35_0    conda-forge
vc                        14                            0    conda-forge
vs2015_runtime            14.0.25420                    0    conda-forge
wheel                     0.31.0                   py35_0    conda-forge
wincertstore              0.2                      py35_0    conda-forge
yaml                      0.1.7                    vc14_0  [vc14]  conda-forge

But when trying to import the package using import pytorch I get:

>>> import pytorch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'pytorch'

And when I try import torch:

>>> import torch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\conner\Anaconda3\envs\pytorch\lib\site-packages\torch\__init__.py", line 76, in <module>
    from torch._C import *
ImportError: DLL load failed: The specified module could not be found.

The difference in errors is actually encouraging, but I don't know how to interpret it. Why am I not able to import pytorch if it shows up on the list of packages in the environment?

EDIT

After continued attempts, I'll ask a much more general question: Has anyone had success at installing and importing Pytorch for Windows 10 on a 64-bit machine?

2

There are 2 best solutions below

0
Deepthi Raj - Intel On

When I installed pytorch by creating a conda environment, it worked fine.

Below are the steps that I tried out. Please try it from your side.

  1. conda create -n (env_name) python=3.5
  2. source activate (env_name)
  3. conda install pytorch-cpu -c pytorch
  4. pip install torchvision
0
Conner M. On

What finally ended up working was to reinstall the entire Anaconda package, although this seems less than ideal.