gpt4 book ai didi

python - 尽管已安装,但无法加载 torchvision

转载 作者:太空宇宙 更新时间:2023-11-03 10:50:45 25 4
gpt4 key购买 nike

我已经使用以下方法安装了 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.

最佳答案

通过运行修复:

conda install pytorch-cpu -c pytorch 
pip install torchvision

删除站 pip 包中的 PIL 和 pillow 文件夹,然后运行:

pip install pillow

关于python - 尽管已安装,但无法加载 torchvision,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50960830/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com