python 深度学习 解决遇到的报错问题9

本篇继python 深度学习 解决遇到的报错问题8-CSDN博客

目录

一、can only concatenate str (not "int") to str

二、can't convert np.ndarray of type numpy.object_. The only supported types are: float64, float32, float16, complex64, complex128, int64, int32, int16, int8, uint8, and bool.

三、module 'd2l.torch' has no attribute 'train_ch3'

四、ERROR: Could not install packages due to an OSError: [WinError 5] 拒绝访问。: 'D:\\my\\python-pycharm\\python-envs\\venv-deep\\Lib\\site-packages\\matplotlib\\_c_internal_utils.cp39-win_amd64.pyd'Check the permissions.

五、ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.

六、'gbk' codec can't decode byte 0xaf in position 33: illegal multibyte sequence


一、can only concatenate str (not "int") to str

报错:inputs.fillna(inputs.mean()) 

原因:原因是第2列识别为str,无法进行数值平均运算。

解决方法: 我们在括号加入限制条件,仅在数据类型为数值的列进行平均值插值。

二、can't convert np.ndarray of type numpy.object_. The only supported types are: float64, float32, float16, complex64, complex128, int64, int32, int16, int8, uint8, and bool.

报错:

原因:读入的numpy数组里的元素是object类型,无法将这种类型转换成tensor。

解决方法:将numpy数组进行强制类型转换成float类型(或者任何pytorch支持的类型:float64, float32, float16, int64, int32, int16, int8, uint8, and bool)

三、module 'd2l.torch' has no attribute 'train_ch3'

报错:'d2l.torch' has no attribute 'train_ch3'

原因:原因就是它和书上要求的d2l版本不同,书上要求d2l版本为0.17.5

解决方法:先卸载旧的版本,

pip uninstall d2l

再下载新的版本,需要以管理员身份运行下载指令,

pip install d2l==0.17.5 --user

如果没有执行成功,试试去掉“--user”,

pip install d2l==0.17.5 -i http://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn

 然后,重新执行代码,

OK,问题解决了。

四、ERROR: Could not install packages due to an OSError: [WinError 5] 拒绝访问。: 'D:\\my\\python-pycharm\\python-envs\\venv-deep\\Lib\\site-packages\\matplotlib\\_c_internal_utils.cp39-win_amd64.pyd'
Check the permissions.

报错:安装指定版本的d2l时报错

解决方法:需要加上“--user”,

pip install d2l==0.17.5 --user

但是立马报错了,

解决方法如下。

五、ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.

报错:

原因:因为在虚拟环境中找不到用户目录,所以不被允许使用 --user 参数来安装包的。

解决方法:打开自己的虚拟环境下的这个pyvenv.cfg文件,

然后,修改include-system-site-packages = true,

OK,解决了。

六、'gbk' codec can't decode byte 0xaf in position 33: illegal multibyte sequence

报错:

原因:这个是编码问题,在打开文件的时候加上编码指定即可

解决方法:需要修改dl的源码,按住ctrl,鼠标点击进入到这个方法,

继续,按住ctrl,鼠标点击进入到这个方法, 

可以看到,这儿是读取了一个txt文件,在open的时候加上编码encoding=‘UTF-8’,

修改完重启jupyter就好了,然后重新执行代码。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

水w

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值