首页 > 其他分享 >动手学深度学习v2(李沐2021版),from d2l import torch as d2l报错

动手学深度学习v2(李沐2021版),from d2l import torch as d2l报错

时间:2024-01-25 21:35:23浏览次数:27  
标签:__ torchvision Image torch 报错 d2l import

 

点击查看代码
%matplotlib inline#该项事实也无法运行
from d2l import torch as d2l#此行报错如下所示
点击查看代码
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[89], line 1
----> 1 from d2l import torch as d2l

File E:\DeepLearning\anaconda3\envs\D2L-pytorch\lib\site-packages\d2l\torch.py:6
      4 import numpy as np
      5 import torch
----> 6 import torchvision
      7 from PIL import Image
      8 from torch import nn

File E:\DeepLearning\anaconda3\envs\D2L-pytorch\lib\site-packages\torchvision\__init__.py:5
      2 import warnings
      4 import torch
----> 5 from torchvision import datasets
      6 from torchvision import io
      7 from torchvision import models

File E:\DeepLearning\anaconda3\envs\D2L-pytorch\lib\site-packages\torchvision\datasets\__init__.py:1
----> 1 from ._optical_flow import KittiFlow, Sintel, FlyingChairs, FlyingThings3D, HD1K
      2 from .caltech import Caltech101, Caltech256
      3 from .celeba import CelebA

File E:\DeepLearning\anaconda3\envs\D2L-pytorch\lib\site-packages\torchvision\datasets\_optical_flow.py:10
      8 import numpy as np
      9 import torch
---> 10 from PIL import Image
     12 from ..io.image import _read_png_16
     13 from .utils import verify_str_arg

File E:\DeepLearning\anaconda3\envs\D2L-pytorch\lib\site-packages\PIL\Image.py:82
     73 MAX_IMAGE_PIXELS = int(1024 * 1024 * 1024 // 4 // 3)
     76 try:
     77     # If the _imaging C module is not present, Pillow will not load.
     78     # Note that other modules should not refer to _imaging directly;
     79     # import Image and use the Image.core variable instead.
     80     # Also note that Image.core is not a publicly documented interface,
     81     # and should be considered private and subject to change.
---> 82     from . import _imaging as core
     84     if __version__ != getattr(core, "PILLOW_VERSION", None):
     85         msg = (
     86             "The _imaging extension was built for another version of Pillow or PIL:\n"
     87             f"Core version: {getattr(core, 'PILLOW_VERSION', None)}\n"
     88             f"Pillow version: {__version__}"
     89         )

ImportError: DLL load failed while importing _imaging: 找不到指定的模块。
该处错误是由于pillow版本太高导致的python版本不匹配导致的

现有环境:pillow10.0.0,python3.9,torch1.12,cuda11.8
处理方式:
先卸载原有pillow版本
pip uninstall pillow
再安装老版本的pillow
pip install pillow==9.0

标签:__,torchvision,Image,torch,报错,d2l,import
From: https://www.cnblogs.com/vincent-IT-info/p/17988218

相关文章

  • VMware下Windows 7安装VMware Tools报错处理
    症状首先安装时它会弹窗选择始终安装最终安装中还是会弹窗提示...驱动安装失败,需要手动安装处理办法由于微软更新了驱动程序签名算法,2019年开始弃用SHA1,改用SHA2。猜测VMwareTools驱动程序使用SHA2,而Windows7只支持SHA1,需要下载安装补丁kb4474419来支持SHA2算法。......
  • scheduler报错: Failed to watch *v1beta1.PodDisruptionBudget: failed to list *v1b
    问题Failedtowatch*v1beta1.PodDisruptionBudget:failedtolist*v1beta1.PodDisruptionBudget:theservercouldnotfindtherequestedresourcenokind"KubeSchedulerConfiguration"isregisteredforversion"componentconfig/v1alpha1"......
  • SQLServer 导入 Excel 表数据报错“文本被截断。。。”
    报错详情(关键信息就是:文本被截断)错误0xc020901c:数据流任务1:输出“Excel源输出”(9)上的输出列“xxxxx”(78)出错。返回的列状态是:“文本被截断,或者一个或多个字符在目标代码页中没有匹配项。”。注:其中,‘xxxxx’代表的是列名,数字‘78’代表的是行序。报错原因文本......
  • Docker启动Nacos报错:Nacos Server did not start because dumpservice bean construct
    一、表象重启服务器之后Docker运行Nacos容器,启动成功,但是外网无法访问。查看了一下Nacos启动日志(dockerlogsnacos容器名)二、分析很明显是数据库配``置问题。。如果是数据库配置的问题,可以着重检查以下信息尤其是MySQL内网Host,查询方式见Docker安装Nacos三、解决我已......
  • Canal报错总结
    这是我的SQL表里面插入数据刷新下就可以看到已经查询出来了canal报错nosuchmethod…bytebuffer解决方法:更新jdk版本与es一致cancal报错configdirnotfound替换classpath中间封号两边的值canal控制台乱码将其改为GBK即可ERRORc.a.otter.canal.adapter.launcher......
  • /run/initramfs/rdsosreport.txt 报错
     vmwarecentos7虚拟机出现Generating/run/initramfs/rdsosreport.txt问题? 解决步骤1.使用命令ls/dev/mapper列出/dev/mapper目录下的文件,查看后缀为“-root”的文件ls/dev/mapper#接着大概率会出现这三个文件centos-rootcentos-swapcontrol2.使用命令xfs_repai......
  • 为啥赋值他就报错JSONDecodeError?
    大家好,我是皮皮。一、前言前几天在Python最强王者交流群【哎呦喂 是豆子~】问了一个Python解析的问题。问题如下:大佬们谁有时间帮忙看下这个情况 好奇怪哦 为啥赋值他就报错JSONDecodeError:Expectingvalue:line1column1(char0)load是load文件,loads才是数据。......
  • webstorm报错:ESLint: TypeError: this.libOptions.parse is not a function
     解决办法:把 {**/*,*}.{js,ts,jsx,tsx,html,vue}换成{**/*,*}.(js,ts,jsx,tsx,html,vue) 原文:https://stackoverflow.com/questions/73509984/eslint-typeerror-this-liboptions-parse-is-not-a-functionMyfriends,ifyouareusing Webstorm orany Jetbrains p......
  • petalinux 报错总结
    Failedtomenuconfigprojectcomponent....解决办法此处是由于Terminal(终端)的界面太窄导致的,把Terminal(终端)界面拉宽即可;重新执行命令【petalinux-config--get-hw-description=*.xsa“path”】后,可以看到配置界面弹出来了,且没有了刚刚的错误。do_rootfs:Thepostinstall......
  • ChatGPT无法登录报错something went wrong. please make sure your device's date and
    这两天Android在登陆ChatGPT的时候,出现错误:somethingwentwrong.pleasemakesureyourdevice'sdateandtimearesetproperly如下图:这个问题就出现的非常蹊跷,于是我在网上搜索了一圈,很多的教程都指向节点网络问题,但是我的Hostease网络确定没有问题,因此这个问题就快无解了,正......