问题描述:
嵩天老师课上代码运行时出现两个问题:
1、无Qt平台插件错误(解决了很久):This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.;
2、参数不对应ValueError: The number of FixedLocator locations (7), does not match the number of ticklabels (6).
代码:
问题1:
问题解决:
问题1:一开始以为是pyqt5安装有问题,尝试卸载重新安装,文件安装未解决,逐行检查代码发现问题出在调用matplotlib库代码行,搜索找到其他博主解决方法,即新建系统变量:解决This application failed to start because no Qt platform plugin could be initialized的办法_KB_talk的博客-CSDN博客https://blog.csdn.net/qq_43903004/article/details/113878306
划重点:变量值需要输入plugin路径,首先你要能找到你的python文件夹位置,然后依次以下路径,将路径地址复制到变量值位置,变量名我按原博主写的QT_PLUGIN_PATH
\Python\Python310(首先要知道这个位置)\Lib\site-packages\PyQt5\Qt5\plugins
至此问题1 解决
问题2:网上回答这个问题的比较多,我是参考下面这篇文章解决的
霍兰德人格分析雷达图生成报错ValueError:he number of FixedLoca和AttributeError: ‘Text‘ object has no property ‘frac‘_ff99717的博客-CSDN博客霍兰德人格分析雷达图生成报错ValueError:he number of FixedLoca和AttributeError: 'Text' object has no property 'frac'报错为:ValueError: The number of FixedLocator locations (7), usually from a call to set_ticks, does not match the number of ticklabels (6).则只需删除红色矩形框1中的内容如https://blog.csdn.net/a147225/article/details/112674969关于7和6的问题有两种解决方案:
(1)添加绿色行代码:radar_labels = np.concatenate((radar_labels, [radar_labels[0]]))
(2)删除红色行代码:data = np.concatenate((data, [data[0]]))
angles = np.concatenate((angles, [angles[0]]))