文章目录
- 1、module 'sklearn' has no attribute 'datasets'
- 2、module 'seaborn' has no attribute 'load_dataset'
- 3、fit_transform() missing 1 required positional argument: 'X'
- 4、ValueError: query data dimension must match training data dimension
- 5、unindent does not match any outer indentation level
- 6、inconsistent use of tabs and spaces in indentation
- 7、GraphViz's executables not found
- 8、invalid literal for int() with base 10
- 9、'gbk' codec can't decode byte 0x93 in position 344: illegal multibyte sequen
- 10、'str' object has no attribute 'decode'、
- 11、python下cv.waitKey无响应原因
- 12、sequence too large; cannot be greater than 32
- 13、UserWarning: Matplotlib is currently using module://ipykernel.pylab.backend_inline, which is a non-GUI backend, so cannot show the figure.
- 14、error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv
- 15、PIL库使用resize函数后图片大小不变
- 16、SyntaxError: name 'xxxxx' is used prior to global declaration
- 17、'dict' object has no attribute 'has_key'
- 18、ValueError: could not convert string to float
- 19、RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available()
- 20、ValueError: Expected 2D array, got 1D array instead
- 21、KeyError: 'A'
- 22、IndexError: Caught IndexError in DataLoader worker process 0.
- 23、RuntimeError: Dataset not found or corrupted. You can use download=True to download it
- 24、IndexError: too many indices for tensor of dimension 0
- 25、AssertionError: Torch not compiled with CUDA enabled
- 26、SyntaxError: unexpected EOF while parsing
- 27、AttributeError: module 'numpy.random' has no attribute 'default_rng'
- 28、UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa1 in position 6: invalid start byte
- 29、AttributeError: type object 'Word2Vec' has no attribute 'LineSentences'
- 30、SyntaxError: invalid character in identifier
- 31、ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- 32、TypeError: Invalid shape (3, 32, 32) for image data
- 33、NoneType : object has no attribute shape
- 34、ImportError: cannot import name xxx from
- 35、ImportError: No module named **
1、module ‘sklearn’ has no attribute ‘datasets’
将 import sklearn 改成了 from sklearn import datasets 就好了
看网上的博客好像是因为安装的模块版本不对
2、module ‘seaborn’ has no attribute ‘load_dataset’
我把当前文件命名成了seaborn.py,应该是起了冲突,改名后就好了
3、fit_transform() missing 1 required positional argument: ‘X’
因为 StandardScaler.fit_transform() 中的 StandardScaler 后面没有加括号
改成StandardScaler().fit_transform()就好了
4、ValueError: query data dimension must match training data dimension
查询数据维度必须与训练数据维度匹配
注意检查传入参数的数据维度
5、unindent does not match any outer indentation level
缩进问题,可能会有看不到的空格等字符
解决方法:
①将代码放到notepad++中,点击“视图”——>“显示符号”——>“显示空格与制表符”
②此时就可以看到代码中所有的空格和制表符了,将代码左边的空格全部删去,并用制表符代替即可
6、inconsistent use of tabs and spaces in indentation
解决方法同上
7、GraphViz’s executables not found
链接:https://blog.csdn.net/qq_42700429/article/details/82927961
加上下面两行代码即可
import os
os.environ["PATH"] += os.pathsep + 'C:/Program Files (x86)/Graphviz2.38/bin/'
8、invalid literal for int() with base 10
int() 只能将字符型的数字转化为整型,如果传入的参数不是字符数字,就会报错
9、‘gbk’ codec can’t decode byte 0x93 in position 344: illegal multibyte sequen
要处理的字符串本身不是gbk编码,但是却以gbk编码去解码
在open(file, encoding=‘utf-8’)中修改解码方式
10、‘str’ object has no attribute ‘decode’、
链接:https://blog.csdn.net/qq_38890412/article/details/86591294
11、python下cv.waitKey无响应原因
要先点击一下弹出的窗口,在窗口输入
12、sequence too large; cannot be greater than 32
直接使用np.array()