【Python】Pandas Excel file format cannot be determined, you must specify an engine manually.报错【已解决】

这篇具有很好参考价值的文章主要介绍了【Python】Pandas Excel file format cannot be determined, you must specify an engine manually.报错【已解决】。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

1、int() argument must be a string, a bytes-like object or a number, not ‘KeyboardModifier‘

说明

根据Python官网,Python3.7还支持WIN7。
项目对应的requirements.txt为:

cycler==0.11.0
fonttools==4.38.0
kiwisolver==1.4.4
matplotlib==3.5.3
Nuitka==1.5.7
numpy==1.21.6
ordered-set==4.1.0
packaging==23.1
Pillow==9.5.0
pyparsing==3.0.9
PySide2==5.15.2.1
python-dateutil==2.8.2
shiboken2==5.15.2.1
six==1.16.0
typing-extensions==4.5.0
zstandard==0.21.0

项目对应的nuitka命令为:

nuitka --standalone  --output-dir=out  --plugin-enable=pyside2  --nofollow-import-to=tkinter  --windows-disable-console

解决方案

from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar

报错主要是PySide6与matplotlib之间接口兼容性的问题。报错位置代码

_MODIFIER_KEYS = [
    (_to_int(getattr(_enum("QtCore.Qt.KeyboardModifier"), mod)),
     _to_int(getattr(_enum("QtCore.Qt.Key"), key)))
    for mod, key in [
        ("ControlModifier", "Key_Control"),
        ("AltModifier", "Key_Alt"),
        ("ShiftModifier", "Key_Shift"),
        ("MetaModifier", "Key_Meta"),
    ]
]

根据gpt,

这段代码是一个用于将 Qt 的键盘修饰符和按键转换为整数类型的列表。具体来说,代码中定义了一个名为 _MODIFIER_KEYS 的列表,其中包含了 4 个二元组,每个二元组分别表示一个修饰符和对应的按键,且每个元素都是整数类型。
这段代码通过调用 getattr() 方法获取了 PySide6.QtCore.Qt.KeyboardModifier 和 PySide6.QtCore.Qt.Key 枚举类对应的属性,使用 _to_int() 函数将枚举值转换为整数类型,并最终构造成二元组的形式存放在 _MODIFIER_KEYS 列表中。
这个列表可以用于接收 Qt 的快捷键事件后进行处理,比如判断按下的键是否为某个快捷键等。
需要注意的是,这里使用了 _enum() 函数获取枚举类,但代码中未给出该函数的实现,可能是在其他地方定义的函数,因此如果要运行这段代码,还需要先确保 _enum() 函数已经定义并导入。

根据matplotlib官方issues,解决方案是,

mpl 升级到 >=3.6.2 或将 pyside 降级到 <6.4.0

Python3.7下matplotlib,最高支持3.5,因而使用pyside==6.3.0,此时需要注意NavigationToolbar2QT需要canvas,parent两个参数。

class NavigationToolbar2QT(NavigationToolbar2, QtWidgets.QToolBar):
.......
    def __init__(self, canvas, parent, coordinates=True):
.......

2、Pandas Excel file format cannot be determined, you must specify an engine manually.

说明

Pandas读取Excel报错
Excel file format cannot be determined, you must specify an engine manually.
【Python】Pandas Excel file format cannot be determined, you must specify an engine manually.报错【已解决】,# Debug,面向百度编程,pandas,python,excel
pd.read_excel方法本身是支持多种引擎的,包括"xlrd", “openpyxl”, “odf”, “pyxlsb”,更换引擎后依然失效!

Debug

我们直接用可以直接用open with打开源文件

    with open(ipath, 'r', encoding='utf-8') as f:
        print(f.read())

神奇的一幕发生了,
【Python】Pandas Excel file format cannot be determined, you must specify an engine manually.报错【已解决】,# Debug,面向百度编程,pandas,python,excel
有的文件名义上是Excel,其实内心是个Html!

解决办法

使用pd.read_html方法文章来源地址https://www.toymoban.com/news/detail-528006.html

df = pd.read_html(ipath, header=2)[0]

到了这里,关于【Python】Pandas Excel file format cannot be determined, you must specify an engine manually.报错【已解决】的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Build input file cannot be found: .pch

    xcode真机运行时,报错: Build input file cannot be found: /Users/mac/Desktop/projects/xxx/xxx.pch 实际查看发现,项目中的.pch文件存在,但运行时报错。修改配置里的.pch文件路径后,正常。

    2024年02月13日
    浏览(25)
  • cannot be resolved to absolute file path because it does not reside in the file system 问题解决

    在Springboot中利用Resource来获取文件并在前端返回该文件, 本地测试正常, 打包到远程报错: cannot be resolved to absolute file path because it does not reside in the file system 紧接上一个问题: 项目打包成 jar 后包无法读取src/main/resources下文件, 在Springboot打包之后, 无法读取到jar包内的文件, 因此

    2023年04月18日
    浏览(35)
  • TypeError: Descriptors cannot not be created directly. If this call came from a _pb2.py file……

    TypeError: Descriptors cannot not be created directly. If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc = 3.19.0. If you cannot immediately regenerate your protos, some other possible workarounds are: 1. Downgrade the protobuf package to 3.20.x or lower. 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATIO

    2024年02月09日
    浏览(36)
  • 无法加载文件 C:\Program Files\nodejs\npm.ps1,因为在此系统上禁止运行脚本。npm.ps1 cannot be loaded

    目录 原因 解决方法  提示 查看当前的执行策略命令 改回默认值 \\\"Restricted\\\"命令 这个错误提示是因为您的系统禁止执行 PowerShell 脚本。 现用执行策略是 Restricted(默认设置) 以管理员身份运行 PowerShell:右键单击 PowerShell 快捷方式,然后选择“以管理员身份运行”。 修改 P

    2024年02月15日
    浏览(51)
  • Cannot determine value type from string ‘xxx‘

    Cannot determine value type from string ‘xxx’ 意思是:找不到相匹配的值或者类型,一般在查询数据库数据的时候报错 错误情况有两种 实体类xxx.java里面的数据类型与数据库类型不匹配 使用了数据个数不完全的有参构造,而没有无参构造 我的情况属于第2种,如下 解决方案:添加无

    2024年02月15日
    浏览(33)
  • Python Pandas 处理Excel数据 制图

    目录 1、饼状图  2、条形统计图

    2024年02月11日
    浏览(29)
  • 初学python系列: pandas操作excel

    媳妇工作中经常用到excel处理,想用python处理excel更高效,所以自学了python,觉得python比Java还是简单多了,没有变量类型声明,比Java也就多了元组,各种库很丰富。 需求是: 汇总两个excel中 列,放到一个新的excel中,不允许有重复的列内容 代码编辑器:pycharm社区版本(根本

    2024年01月22日
    浏览(35)
  • Python:使用pandas对excel数据筛选选择

    #直接筛选 #DataFrame索引使用[], #直接索引语法:df[] 1.1 直接筛选,选择单列数据:df[\\\"列\\\"] 1.2直接筛选,选择多列数据:df[[\\\"列1\\\",\\\"列2\\\"]](注意:多嵌套列) 1.3直接筛选,选择多行数据:df[2:4]按照位置选取连续的行(切片),前闭后开 #(\\\'----------筛选方式2:条件筛选-------------\\\') #条件筛选

    2024年02月16日
    浏览(40)
  • Python之如何使用pandas操作Excel表

    目录 1、前言 2、读取Excel 3、对Excel进行操作 3.1、获取行号、列名  3.2、获取单元格的值,并循环输出  3.3、对空值进行处理,替换  3.4、增加一列,并对新增列的第一行进行赋值 3.5、将修改后数据保存到原文档  3.6、关于循环取数 4、错误处理 5、全部代码 1、前言 网上也有

    2023年04月09日
    浏览(40)
  • 【Python】使用pandas将数据写入excel文件中

    本文主要简单介绍一下使用python的pandas库来将数据写入到excel文件中。 示例:pandas 是基于NumPy 的一种工具,该工具是为了解决数据分析任务而创建的。在命令行输入pip install pandas进行安装即可,如果安装不成功,有安装Pycharm的小伙伴也可以进入python interpreter界面,搜索pand

    2024年02月15日
    浏览(41)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包