BUG合集

这篇博客汇总了Python编程中遇到的一些错误,包括AttributeError、安装opencv-python的错误、h5py文件打开问题、磁盘空间不足的OSError以及FutureWarning。同时,也列举了在Linux命令行环境下-bash: ***: command not found和运行shell脚本时command not found的问题及其解决方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Python

1

File “/home/XXX/Code/…”, line 50, in init
self.input_shape = input_shape
File “/home/XXX/.local/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py”, line 1639, in setattr
super(Layer, self).setattr(name, value)
AttributeError: can’t set attribute

  • 解决方案
    被赋值的变量与super的属性重名了,且其不是一个setter,更改一下变量名,改为“self.inputShape = input_shape”就可以了。
    参考链接
2

Pycharm/Python OpenCV and CV2 install error
ERROR: Could not find a version that satisfies the requirement cv2 (from versions: none)
ERROR: No matching distribution found for cv2

  • 解决方案
    You are getting those errors because opencv and cv2 are not the python package names.
    These are both included as part of the opencv-python package available to install from pip.
    https://stackoverflow.com/questions/37776228/pycharm-python-opencv-and-cv2-install-error
3

File “h5py/_objects.pyx”, line 54, in h5py._objects.with_phil.wrapper
File “h5py/_objects.pyx”, line 55, in h5py._objects.with_phil.wrapper
File “h5py/h5f.pyx”, line 78, in h5py.h5f.open
OSError: Unable to open file (file signature not found)

  • 解决方案
    源文件下载的时候有问题,在网页从download进再下载一次;检查上一次访问该文件时是否用close()正常关闭了
    https://github.com/h5py/h5py/issues/757
4

OSError: Driver write request failed (file write failed: time = Mon May 27 10:45:48 2019
, filename = ‘shapes_20x20/16_32/result_4.h5’, file descriptor = 24, errno = 28, error message = ‘No space left on device’, buf = 0x564b1eef09e6, total write size = 13279, bytes this sub-write = 13279, bytes actually written = 18446744073709551615, offset = 92549120)

  • 解决方案
    通过命令 sudo du -h --max-depth=1,查看内存使用情况,清理一下内存
5

FutureWarning: The behavior of AMI will change in version 0.22. To match the behavior of ‘v_measure_score’, AMI will use average_method=‘arithmetic’ by default.

  • 解决方案:使用
    from sklearn.metrics.cluster import adjusted_mutual_info_score adjusted_mutual_info_score(labels_true, labels_pred, average_method='arithmetic')

命令行

1

linux下-bash: ***: command not found

  • 解决方案
    一般就是最近添加PATH路径的时候没有写对,一种直接的方法就是进入 /etc 文件夹,用文本编辑修改正确profile文件,可能会提示没有权限修改,复制到别的文件夹改好后再copy回来;或者参考下面的链接
    linux下-bash: ***: command not found解决办法
2

使用‘./run.sh’命令出现错误:running shell script: command not found

  • 解决方案(参考自https://www.linuxquestions.org/questions/red-hat-31/running-shell-script-command-not-found-202062/)
    先通过 chmod u+x run.sh 给权限,再./run.sh
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值