Python常见报错
sweettea~
菜鸡AI选手,随手记录可行codes or tricks助力自己和别人~
展开
-
Python报错:RuntimeError: The ‘data‘ object was created by an older version of PyG.
Python报错:RuntimeError: The 'data' object was created by an older version of PyG.原创 2023-07-31 17:03:27 · 1857 阅读 · 3 评论 -
Python报错:IndexError: invalid index of a 0-dim tensor. Use `tensor.item()` in
Python报错:IndexError: invalid index of a 0-dim tensor. Use `tensor.item()` in原创 2023-08-08 10:36:16 · 1171 阅读 · 0 评论 -
3步安装torch_geometric
安装torch_geometric原创 2023-03-10 16:46:11 · 597 阅读 · 1 评论 -
Python报错:TypeError: load() missing 1 required positional argument: ‘Loader‘
Python报错:TypeError: load() missing 1 required positional argument: ‘Loader‘原创 2023-01-04 16:42:55 · 984 阅读 · 0 评论 -
ipykernel_launcher.py: error: unrecognized arguments: -f /home/
ipykernel_launcher.py: error: unrecognized arguments: -f /home/原创 2023-01-03 20:03:43 · 1533 阅读 · 0 评论 -
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace原创 2023-01-03 20:03:26 · 276 阅读 · 0 评论 -
TypeError: can‘t convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory
TypeError: can‘t convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory原创 2023-01-03 20:03:38 · 526 阅读 · 0 评论 -
InvalidIndexError: (slice(None, None, None), None)
InvalidIndexError: (slice(None, None, None), None)原创 2023-01-03 20:04:33 · 2265 阅读 · 0 评论 -
AttributeError: ‘list‘ object has no attribute ‘shape‘
AttributeError: 'list' object has no attribute 'shape'原创 2023-01-03 20:04:40 · 4919 阅读 · 0 评论 -
yaml.constructor.ConstructorError: could not determine a constructor for the tag ‘tag:yaml.org,2
yaml.constructor.ConstructorError: could not determine a constructor for the tag ‘tag:yaml.org,2原创 2023-01-04 15:52:43 · 1062 阅读 · 0 评论 -
ValueError: Object arrays cannot be loaded when allow_pickle=False
ValueError: Object arrays cannot be loaded when allow_pickle=False原创 2023-01-02 13:47:42 · 243 阅读 · 0 评论 -
TypeError: loop of ufunc does not support argument 0 of type str which has no callable log method
TypeError: loop of ufunc does not support argument 0 of type str which has no callable log method原创 2023-01-02 13:42:47 · 786 阅读 · 0 评论 -
Python报错can‘t convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first
Python报错can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first原创 2023-01-02 13:40:31 · 1658 阅读 · 0 评论 -
Torch,Numpy,Pandas转换
Torch,Numpy,Pandas转换原创 2023-01-02 13:25:53 · 238 阅读 · 0 评论 -
Python报错:ValueError: too many values to unpack
Python报错:ValueError: too many values to unpack原创 2023-01-02 13:16:38 · 2423 阅读 · 0 评论 -
用pandas读取csv文件的前n行
用pandas读取csv文件的前n行原创 2023-01-01 19:40:22 · 2522 阅读 · 0 评论 -
如何将GPU中list类型数据转移到CPU
如何将GPU中list类型数据转移到CPU原创 2023-01-01 19:37:29 · 2108 阅读 · 3 评论 -
Python报错:AttributeError: ‘numpy.ndarray‘ object has no attribute ‘iloc‘
Python报错:AttributeError: 'numpy.ndarray' object has no attribute 'iloc'原创 2023-01-01 19:32:16 · 4636 阅读 · 0 评论 -
Python报错:IndexError: index 0 is out of bounds for axis 0 with size 0
Python报错:IndexError: index 0 is out of bounds for axis 0 with size 0原创 2023-01-01 19:29:47 · 21873 阅读 · 1 评论 -
kaggle/天池等平台使用args报错
kaggle/天池等平台使用args报错原创 2023-01-01 19:25:02 · 132 阅读 · 0 评论 -
Python报错:ValueError: Classification metrics can‘t handle a mix of binary and continuous targets
Python报错:ValueError: Classification metrics can‘t handle a mix of binary and continuous targets原创 2023-01-01 19:18:40 · 6125 阅读 · 0 评论 -
Python报错:TypeError: Cannot interpret ‘4‘ as a data type
Python报错:TypeError: Cannot interpret ‘4‘ as a data type原创 2023-01-01 19:04:03 · 1884 阅读 · 0 评论 -
Python报错:ValueError: Type must be a sub-type of ndarray type
Python报错:ValueError: Type must be a sub-type of ndarray type原创 2023-01-01 18:59:25 · 3698 阅读 · 0 评论 -
Python报错:RuntimeError: one of the variables needed for gradient computation has been modified by
Python报错:RuntimeError: one of the variables needed for gradient computation has been modified by原创 2022-09-27 20:19:59 · 1041 阅读 · 0 评论 -
Python报错:TypeError: __init__() got an unexpected keyword argument ‘n_jobs‘
Python报错:TypeError: __init__() got an unexpected keyword argument 'n_jobs'原创 2022-07-20 20:37:29 · 14272 阅读 · 1 评论 -
Python报错:TypeError: load() missing 1 required positional argument: ‘Loader‘
Python报错:TypeError: load() missing 1 required positional argument: 'Loader'原创 2022-07-20 20:31:48 · 1285 阅读 · 2 评论 -
Python报错:name nn is not defined
Python报错:name nn is not defined原创 2022-07-09 19:18:58 · 2161 阅读 · 0 评论 -
Python报错:NameError: name ‘plt‘ is not defined
import matplotlib.pyplot as plt原创 2022-01-05 16:42:47 · 47899 阅读 · 9 评论 -
使用Matplotbib绘图修改中文字体
Matplotlib作图时默认设置下为英文,无法显示中文,只需要添加下面两行代码即可。plt.rcParams['font.sans-serif'] = ['SimHei']plt.rcParams['axes.unicode_minus'] = False实例import matplotlib.pyplot as pltfrom numpy.random import multivariate_normal# 生成二维正态分布数据X = multivariate_normal(mean=原创 2022-01-05 21:24:11 · 960 阅读 · 0 评论 -
Python报错:run.py: error: the following arguments are required: --model
运行报错:run.py: error: the following arguments are required: --model错误原因:需要缺乏配置参数,需要进行相关参数配置。解决办法:在Pycharm的编辑设置,加上–model--model=****,其中****为指定的模型名称,按照自己实际报错进行添加,比如我这里要跑的模型为bert,因此加上–model--model=bert。代码即可正常运行。......原创 2022-03-03 21:00:43 · 24362 阅读 · 6 评论 -
Python报错:RuntimeError: CUDA out of memory. Tried to allocate 48.00 MiB
Python报错:RuntimeError: CUDA out of memory. Tried to allocate 48.00 MiB (GPU 0; 6.00 GiB total capacity; 4.44 GiB already allocated; 0 bytes free; 4.49 GiB reserved in total by PyTorch)可以修改batch_size大小进行解决,例如我是将batch_size = 128改为32即可。......原创 2022-03-03 21:07:44 · 4270 阅读 · 1 评论 -
Python报错:ParserError: Error tokenizing data. C error: Expected 1 fields in line 28591, saw 2
使用pandas读取txt文件时报错如下:ParserError: Error tokenizing data. C error: Expected 1 fields in line 28591, saw 2解决办法:加入 error_bad_lines=False示例代码:Train_data = pd.read_csv(path+'train.txt',error_bad_lines=False)Test_data = pd.read_csv(path+'test.txt',error_ba原创 2022-03-04 15:21:19 · 3110 阅读 · 0 评论 -
Python报错:NameError: name ‘Counter‘ is not defined
Python报错:NameError: name ‘Counter’ is not defined解决办法:加入from collections import Counter即可from collections import Counter原创 2022-03-07 13:52:26 · 9263 阅读 · 0 评论 -
Python由于gensim版本原因Word2vec调用时3个报错问题解决办法
报错1:TypeError: init() got an unexpected keyword argument ‘size‘根据官方手册,将 size改为vector_size报错2:TypeError: init() got an unexpected keyword argument ‘iter‘根据官方手册,将 iter改为epochs报错3:TypeError: ‘Word2Vec’ object is not subscriptable根据官方手册,原始调用词向量直接使用命令model原创 2022-05-16 14:11:25 · 3849 阅读 · 0 评论 -
Python报错 TypeError: Descriptors cannot not be created directly
Python报错TypeError: Descriptors cannot not be created directly原创 2022-06-19 21:18:05 · 13204 阅读 · 10 评论 -
Python报错UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte
Python报错UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte原创 2022-06-20 14:46:51 · 44137 阅读 · 2 评论