我已经使用以下方法安装了pytorch和torchvision:
conda install pytorch-cpu -c pytorch
pip install torchvision
当我尝试在spyder中运行以下命令时:
import torch
import torchvision
import torchvision.transforms as transforms
我得到:
Traceback (most recent call last):
File "<ipython-input-2-0bf25e9dac67>", line 2, in <module>
import torchvision
File "C:\Users\lkoefoed\AppData\Local\Continuum\anaconda3\lib\site-package\torchvision\__init__.py", line 2, in <module>
from torchvision import datasets
File "C:\Users\lkoefoed\AppData\Local\Continuum\anaconda3\lib\site-packages\torchvision\datasets\__init__.py", line 1, in <module>
from .lsun import LSUN, LSUNClass
File "C:\Users\lkoefoed\AppData\Local\Continuum\anaconda3\lib\site-packages\torchvision\datasets\lsun.py", line 2, in <module>
from PIL import Image
File "C:\Users\lkoefoed\AppData\Local\Continuum\anaconda3\lib\site-packages\PIL\Image.py", line 56, in <module>
from . import _imaging as core
ImportError: DLL load failed: The specified module could not be found.
答案 0 :(得分:2)
通过运行修复:
conda install pytorch-cpu -c pytorch
pip install torchvision
在站点软件包中删除PIL和枕头文件夹,然后运行:
pip install pillow
答案 1 :(得分:0)
conda:
conda install torchvision -c pytorch
这对我来说很完美