李沐 动手学深度学习v2 %matplotlib inline问题

问题

导入下面的包后

%matplotlib inline
import torch
import torchvision
from torch import nn
from d2l import torch as d2l

出现下面几个报错

cannot import name 'mplDeprecation' from 'matplotlib._api.deprecation' (D:\environment\work_tool\anaconda3\envs\d2l\lib\site-packages\matplotlib\_api\deprecation.py
cannot import name 'colors' from 'matplotlib'
module 'matplotlib' has no attribute 'rcParams'

解决办法

        本来一直认为是matplotlib的版本问题,换了好多个版本但一直没用,最后从头把所有常用的包删了重装环境时发现问题,在重装d2l包后出现以下报错

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
d2l 0.17.6 requires numpy==1.21.5, but you have numpy 1.22.4 which is incompatible.

       执行安装后出现

ERROR: Could not install packages due to an OSError: [WinError 5] 拒绝访问。: 'D:\\environment\\work_tool\\anaconda3\\envs\\d2l\\Lib\\site-packages\\numpy\\core\\_multiarray_tests.cp39-win_amd64.pyd'
Consider using the `--user` option or check the permissions.

         根据提示加上--user后解决

pip install numpy==1.22.4 --user

        最后将numpy退回1.21.5,但是还是存在不兼容的情况,不过至少想运行的代码能跑起来了。

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
scipy 1.13.1 requires numpy<2.3,>=1.22.4, but you have numpy 1.21.5 which is incompatible.

        从结果来看应该是numpy的库有问题,但报错一直报的是matplotlib,很奇怪,总之要是发现环境报错不如直接按照书上的要求重装一下d2l看看到底是哪里有问题。

pip install d2l==0.17.6

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值