Traceback (most recent call last): File "D:\pypdf2_problem\PDF读取.py", line 3, in <module> for page in file.pages: ^^^^^^^^^^ File "D:\python下载\Lib\site-packages\pdfplumber\pdf.py", line 118, in pages if pp is not None and page_number not in pp: ^^^^^^^^^^^^^^^^^^^^^ TypeError: 'in <string>' requires string as left operand, not int Traceback (most recent call last): File "D:\pypdf2_problem\PDF读取.py", line 3, in <module> for page in file.pages: ^^^^^^^^^^ File "D:\python下载\Lib\site-packages\pdfplumber\pdf.py", line 118, in pages if pp is not None and page_number not in pp: ^^^^^^^^^^^^^^^^^^^^^ TypeError: 'in <string>' requires string as left operand, not int Traceback (most recent call last): File "D:\pypdf2_problem\PDF读取.py", line 3, in <module> for page in file.pages: ^^^^^^^^^^ File "D:\python下载\Lib\site-packages\pdfplumber\pdf.py", line 118, in pages if pp is not None and page_number not in pp: ^^^^^^^^^^^^^^^^^^^^^ TypeError: 'in <string>' requires string as left operand, not int Traceback (most recent call last): File "D:\pypdf2_problem\PDF读取.py", line 3, in <module> for page in file.pages: ^^^^^^^^^^ File "D:\python下载\Lib\site-packages\pdfplumber\pdf.py", line 118, in pages if pp is not None and page_number not in pp: ^^^^^^^^^^^^^^^^^^^^^ TypeError: 'in <string>' requires string as left operand, not int
时间: 2023-08-05 08:09:21 浏览: 127
这个错误表明您的代码中存在类型错误。具体来说,'in <string>'要求左操作数为字符串,而不是整数。请检查您的代码中是否有地方将整数用作字符串的操作数。
另外,请确保您使用的PDF读取库(如pdfplumber)是正确安装并导入的。如果问题仍然存在,请提供您的代码,以便我可以更好地帮助您解决问题。
相关问题
Traceback (most recent call last): File "paddle\fluid\ir.py", line 24, in <module> File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module File "paddle\fluid\proto\pass_desc_pb2.py", line 16, in <module> ModuleNotFoundError: No module named 'framework_pb2' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "main.py", line 1, in <module> File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module File "index.py", line 7, in <module> File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module File "leis\jietuwj.py", line 8, in <module> File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module File "paddleocr\__init__.py", line 14, in <module> File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module File "paddleocr\paddleocr.py", line 21, in <module> File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module File "paddle\__init__.py", line 62, in <module> File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module File "paddle\distributed\__init__.py", line 15, in <module> File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module File "paddle\distributed\spawn.py", line 24, in <module> File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module File "paddle\distributed\utils\launch_utils.py", line 27, in <module> File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module File "paddle\distributed\fleet\__init__.py", line 31, in <module> File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module File "paddle\distributed\fleet\fleet.py", line 33, in <module> File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module File "paddle\fluid\ir.py", line 28, in <module> File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module File "paddle\fluid\proto\pass_desc_pb2.py", line 16, in <module> ModuleNotFoundError: No module named 'framework_pb2' [15508] Failed to execute script 'main' due to unhandled exception!
这是一个 Python 的错误,看起来是在使用 PaddlePaddle 框架时出现了问题。可能是因为缺少某个依赖项或环境配置不正确导致的。你可以尝试更新 PaddlePaddle 和相关的依赖项,或者检查你的环境配置是否正确。如果问题仍然存在,请查看错误信息中的文件和行号,以便更好地定位和解决问题。
Traceback (most recent call last): File "v_1.py", line 4, in <module> File "D:\pycharm\spotweldingevaluation\dist\v_1\numpy\__init__.py", line 140, in <module> from . import core File "D:\pycharm\spotweldingevaluation\dist\v_1\numpy\core\__init__.py", line 9, in <module> from numpy.version import version as __version__ File "D:\pycharm\spotweldingevaluation\dist\v_1\numpy\version.py", line 1, in <module> from __future__ import annotations ModuleNotFoundError: No module named '__future__'
这个错误是由于你的 Python 版本低于 3.7 导致的,__future__ 模块在 Python 3.7 之前是一个内置模块,而在 Python 3.7 及以后的版本中,它被移动到了标准库中,如果你的 Python 版本低于 3.7,就会出现这个错误。你需要升级你的 Python 版本,或者手动添加一个 __future__.py 文件到你的项目中。
阅读全文