2

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?

Conner M.
  • 1,954
  • 3
  • 19
  • 29
  • For your information, `import torch` is the correct command. But I do not know how to fix your error. I always install it with pip if you want to try that. – Matthew Ciaramitaro May 05 '18 at 02:52
  • I've tried just about everything to get it installed including `pip` – Conner M. May 05 '18 at 02:53
  • so what happened when you ran `conda install pytorch torchvision -c pytorch` like it says on the pytorch website – Matthew Ciaramitaro May 05 '18 at 02:54
  • `(C:\Users\conner\Anaconda3) C:\Users\User 1>conda install pytorch torchvision -c pytorch Fetching package metadata ............... PackageNotFoundError: Package missing in current win-64 channels: - torchvision` – Conner M. May 05 '18 at 02:57
  • ah you're using windows. torchvision has to be installed with pip on windows or installed from source – Matthew Ciaramitaro May 05 '18 at 02:57
  • The package is there, just as the second error says, with the other packages installed for the environment I set up. – Conner M. May 05 '18 at 02:58

2 Answers2

0

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

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

Conner M.
  • 1,954
  • 3
  • 19
  • 29