服务器有了网站怎么做的,wordpress 插件查看,建设工程交易中心是什么,教做糕点的视频网站1.在日常工作和学习中#xff0c;遇到类似问题处理场景#xff0c;如pdf文件核心内容截取#xff0c;这里将文件打包成exe可执行文件#xff0c;实现功能简便使用。 2.欢迎点赞、关注、批评、指正#xff0c;互三走起来#xff0c;小手动起来#xff01; 3.欢迎点赞、关… 1.在日常工作和学习中遇到类似问题处理场景如pdf文件核心内容截取这里将文件打包成exe可执行文件实现功能简便使用。 2.欢迎点赞、关注、批评、指正互三走起来小手动起来 3.欢迎点赞、关注、批评、指正互三走起来小手动起来 脚本代码请参考下文章上一篇结果代码也可以到文末。 【python012】Python根据页码处理PDF文件的内容【python012】Python根据页码处理PDF文件的内容 文章目录 1.环境准备2.pyinstaller打包输出脚本工具3.参数及生成文件释义4.打包错误示例及工具代码 1.环境准备
历史安装的环境打包失败或环境包不兼容或历史安装包太多等问题新建环境可能会更快些。问题如4小节记录。# 在 Anaconda Prompt 环境中创建虚拟环境
conda create -n youli python3.8.0# 激活新建的虚拟环境
conda activate youli# 安装必要的Python环境包
pip install fitz
pip install pymupdf
pip install wxpython
pip install pyinstaller
pip install frontend wxpython# 删除虚拟环境
# conda create -n youli python3.8.0# 查看当前存在哪些虚拟环境
# conda env list
# conda info -e虚拟环境效果如下 环境包版本详情如下
2.pyinstaller打包输出脚本工具
命令行pyinstaller -F -w ..\pdfextract.py --noconfirm --noconsole -p ..\Anaconda3\envs\python8\Lib\site-packages执行结果详情(python8) C:\Users\Administratorpyinstaller -F -w ..\pdfextract2.py --noconfirm --noconsole -p ..\Anaconda3\envs\python8\Lib\site-packages
420 INFO: PyInstaller: 6.8.0, contrib hooks: 2024.7
420 INFO: Python: 3.8.0 (conda)
421 INFO: Platform: Windows-10-10.0.19041-SP0
422 INFO: Python environment: ..\Anaconda3\envs\python8
423 INFO: wrote C:\Users\Administrator\pdfextract2.spec
429 DEPRECATION: Foreign Python environments site-packages paths added to --paths/pathex:
[..\\Anaconda3\\envs\\python8\\Lib\\site-packages]
This is ALWAYS the wrong thing to do. If your environments site-packages is not in PyInstallers module search path then you are running PyInstaller from a different environment to the one your packages are in. Run print(sys.prefix) without PyInstaller to get the environment you should be using then install and run PyInstaller from that environment instead of this one. This warning will become an error in PyInstaller 7.0.
430 INFO: Module search paths (PYTHONPATH):
[..\\Anaconda3\\envs\\python8\\Scripts\\pyinstaller.exe,..\\Anaconda3\\envs\\python8\\python38.zip,..\\Anaconda3\\envs\\python8\\DLLs,..\\Anaconda3\\envs\\python8\\lib,..\\Anaconda3\\envs\\python8,..\\Anaconda3\\envs\\python8\\lib\\site-packages,E:\\PycharmSpace\\orclblobtest,..\\Anaconda3\\envs\\python8\\Lib\\site-packages]
733 INFO: checking Analysis
733 INFO: Building Analysis because Analysis-00.toc is non existent
733 INFO: Running Analysis Analysis-00.toc
735 INFO: Target bytecode optimization level: 0
735 INFO: Initializing module dependency graph...
736 INFO: Caching module graph hooks...
754 INFO: Analyzing base_library.zip ...
1824 INFO: Loading module hook hook-heapq.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
1897 INFO: Loading module hook hook-encodings.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
3157 INFO: Loading module hook hook-pickle.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
3815 INFO: Caching module dependency graph...
3965 INFO: Looking for Python shared library...
3973 INFO: Using Python shared library: ..\Anaconda3\envs\python8\python38.dll
3974 INFO: Analyzing E:\PycharmSpace\orclblobtest\pdfextract2.py
5889 INFO: Loading module hook hook-PIL.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
5956 INFO: Loading module hook hook-PIL.Image.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
6952 INFO: Loading module hook hook-numpy.py from ..\\Anaconda3\\envs\\python8\\Lib\\site-packages\\numpy\\_pyinstaller...
7029 WARNING: Conda distribution numpy, dependency of numpy, was not found. If you installed this distribution with pip then you may ignore this warning.
7572 INFO: Loading module hook hook-multiprocessing.util.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
7681 INFO: Loading module hook hook-xml.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
8209 INFO: Loading module hook hook-difflib.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
8295 INFO: Loading module hook hook-platform.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
8669 INFO: Loading module hook hook-sysconfig.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
9621 INFO: Loading module hook hook-packaging.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
9745 INFO: Loading module hook hook-PIL.ImageFilter.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
10018 INFO: Loading module hook hook-pandas.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
11702 INFO: Loading module hook hook-pytz.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
12067 INFO: Loading module hook hook-pkg_resources.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
14388 INFO: Loading module hook hook-scipy.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
14539 INFO: Loading module hook hook-scipy.linalg.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
14909 INFO: Loading module hook hook-scipy.sparse.csgraph.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
15183 INFO: Loading module hook hook-scipy.special._ufuncs.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
15243 INFO: Loading module hook hook-scipy.special._ellip_harm_2.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
16644 INFO: Loading module hook hook-scipy.spatial.transform.rotation.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
17421 INFO: Loading module hook hook-scipy.stats._stats.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
18308 INFO: Loading module hook hook-pandas.io.formats.style.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
20782 INFO: Loading module hook hook-pandas.plotting.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
21009 INFO: Processing pre-safe import module hook six.moves from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-six.moves.py.
22334 INFO: Loading module hook hook-sqlite3.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
22879 INFO: Loading module hook hook-pandas.io.clipboard.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
23076 INFO: Loading module hook hook-xml.etree.cElementTree.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
23078 INFO: Loading module hook hook-lxml.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks...
23627 INFO: Loading module hook hook-lxml.etree.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks...
23633 INFO: Loading module hook hook-xml.dom.domreg.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
24205 INFO: Processing module hooks...
24282 INFO: Loading module hook hook-lxml.isoschematron.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks...
24301 WARNING: Hidden import jinja2 not found!
24515 INFO: Loading module hook hook-PIL.SpiderImagePlugin.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
25007 INFO: Loading module hook hook-lxml.objectify.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks...
25027 INFO: Performing binary vs. data reclassification (624 entries)
25172 INFO: Looking for ctypes DLLs
25217 INFO: Analyzing run-time hooks ...
25225 INFO: Including run-time hook ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgutil.py
25229 INFO: Processing pre-find module path hook _pyi_rth_utils from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-_pyi_rth_utils.py.
25230 INFO: Loading module hook hook-_pyi_rth_utils.py from ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks...
25231 INFO: Including run-time hook ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_multiprocessing.py
25234 INFO: Including run-time hook ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgres.py
25237 INFO: Including run-time hook ..\\Anaconda3\\envs\\python8\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_inspect.py
25287 INFO: Looking for dynamic libraries
..\Anaconda3\envs\python8\lib\site-packages\PyInstaller\building\build_main.py:205: UserWarning: The numpy.array_api submodule is still experimental. See NEP 47.__import__(package)
26904 INFO: Extra DLL search directories (AddDllDirectory): [..\\Anaconda3\\envs\\python8\\lib\\site-packages\\numpy\\.libs]
26904 INFO: Extra DLL search directories (PATH): []
30079 INFO: Warnings written to C:\Users\Administrator\build\pdfextract2\warn-pdfextract2.txt
30264 INFO: Graph cross-reference written to C:\Users\Administrator\build\pdfextract2\xref-pdfextract2.html
30336 INFO: checking PYZ
30337 INFO: Building PYZ because PYZ-00.toc is non existent
30337 INFO: Building PYZ (ZlibArchive) C:\Users\Administrator\build\pdfextract2\PYZ-00.pyz
32361 INFO: Building PYZ (ZlibArchive) C:\Users\Administrator\build\pdfextract2\PYZ-00.pyz completed successfully.
32416 INFO: checking PKG
32416 INFO: Building PKG because PKG-00.toc is non existent
32417 INFO: Building PKG (CArchive) pdfextract2.pkg
59038 INFO: Building PKG (CArchive) pdfextract2.pkg completed successfully.
59060 INFO: Bootloader ..\Anaconda3\envs\python8\lib\site-packages\PyInstaller\bootloader\Windows-64bit-intel\runw.exe
59060 INFO: checking EXE
59061 INFO: Building EXE because EXE-00.toc is non existent
59061 INFO: Building EXE from EXE-00.toc
59061 INFO: Copying bootloader EXE to C:\Users\Administrator\dist\pdfextract2.exe
59067 INFO: Copying icon to EXE
59072 INFO: Copying 0 resources to EXE
59072 INFO: Embedding manifest in EXE
59076 INFO: Appending PKG archive to EXE
59148 INFO: Fixing EXE headers
59664 INFO: Building EXE from EXE-00.toc completed successfully.3.参数及生成文件释义
pyinstaller参数含义 输出文件内容含义 Analysis主要是分析py文件的依赖信息PYZ是一个.pyz的压缩包包含程序运行需要的依赖EXE是根据上述两项内容而生成的COLLECT主要是输出信息dist文件夹:最终的exe文件存放位置build文件夹中间过程创建好之后可以直接删除 整体详情如下图所示
4.打包错误示例及工具代码
错误示例部分 打包代码# -*- coding: utf-8 -*-import fitz
import wxclass PDFExtractor(wx.Frame):def __init__(self, parent, _title):wx.Frame.__init__(self, parent, idwx.ID_ANY, title_title, poswx.DefaultPosition,sizewx.Size(500, 254), stylewx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL )self.SetSizeHints(wx.DefaultSize, wx.DefaultSize)self.SetForegroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW))self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_ACTIVECAPTION))bSizer2 wx.BoxSizer(wx.VERTICAL)self.m_filePicker2 wx.FilePickerCtrl(self, wx.ID_ANY, wx.EmptyString, uSelect a file, u*.*,wx.DefaultPosition, wx.DefaultSize, wx.FLP_DEFAULT_STYLE)self.m_filePicker2.SetFont(wx.Font(9, 74, 90, 92, False, 微软雅黑))self.m_filePicker2.SetForegroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHT))self.m_filePicker2.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHT))bSizer2.Add(self.m_filePicker2, 0, wx.ALL | wx.EXPAND, 5)self.m_staticText5 wx.StaticText(self, wx.ID_ANY, uStart Page, wx.DefaultPosition, wx.DefaultSize, 0)self.m_staticText5.Wrap(-1)self.m_staticText5.SetFont(wx.Font(9, 74, 90, 92, True, 微软雅黑))self.m_staticText5.SetForegroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNTEXT))bSizer2.Add(self.m_staticText5, 0, wx.ALL, 5)self.m_textCtrl1 wx.TextCtrl(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0)bSizer2.Add(self.m_textCtrl1, 0, wx.EXPAND, 5)self.m_staticText6 wx.StaticText(self, wx.ID_ANY, uEnd Page, wx.DefaultPosition, wx.DefaultSize, 0)self.m_staticText6.Wrap(-1)self.m_staticText6.SetFont(wx.Font(9, 74, 90, 92, True, 微软雅黑))self.m_staticText6.SetForegroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNTEXT))bSizer2.Add(self.m_staticText6, 0, wx.ALL, 5)self.m_textCtrl2 wx.TextCtrl(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0)bSizer2.Add(self.m_textCtrl2, 0, wx.EXPAND, 5)self.m_button18 wx.Button(self, wx.ID_ANY, uExtract, wx.DefaultPosition, wx.DefaultSize, wx.NO_BORDER)self.m_button18.SetFont(wx.Font(12, 74, 90, 92, False, 微软雅黑))self.m_button18.SetForegroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNTEXT))self.m_button18.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNHIGHLIGHT))self.m_button18.Bind(wx.EVT_BUTTON, self.extract_pages)bSizer2.Add(self.m_button18, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.SHAPED, 5)self.SetSizer(bSizer2)self.Layout()self.Centre(wx.BOTH)def __del__(self):passdef extract_pages(self, event):file_path self.m_filePicker2.GetPath()start_page int(self.m_textCtrl1.GetValue())end_page int(self.m_textCtrl2.GetValue())doc fitz.open(file_path)output_doc fitz.open()for page_num in range(start_page - 1, end_page):output_doc.insert_pdf(doc, from_pagepage_num, to_pagepage_num)output_path file_path.replace(.pdf, _extracted.pdf)output_doc.save(output_path)output_doc.close()doc.close()wx.MessageBox(Extraction complete!, Success, wx.OK | wx.ICON_INFORMATION)# app wx.App()
# PDFExtractor(None, titlePDF Extractor)
# app.MainLoop()if __name__ __main__:app wx.App() # 运行wx.App()方法title PDF Extractorframe PDFExtractor( None , title ) # 调用Frame类并且不指定父类当前就成为父类frame.Show() # 运行展示界面的方法Show()app.MainLoop() # 进入程序wx.App()循环 文章转载自: http://www.morning.brbmf.cn.gov.cn.brbmf.cn http://www.morning.rymd.cn.gov.cn.rymd.cn http://www.morning.bwxph.cn.gov.cn.bwxph.cn http://www.morning.itvsee.com.gov.cn.itvsee.com http://www.morning.tkrwm.cn.gov.cn.tkrwm.cn http://www.morning.lhqw.cn.gov.cn.lhqw.cn http://www.morning.rtryr.cn.gov.cn.rtryr.cn http://www.morning.lyhry.cn.gov.cn.lyhry.cn http://www.morning.rttp.cn.gov.cn.rttp.cn http://www.morning.sbkb.cn.gov.cn.sbkb.cn http://www.morning.dmjhp.cn.gov.cn.dmjhp.cn http://www.morning.wnkbf.cn.gov.cn.wnkbf.cn http://www.morning.bpptt.cn.gov.cn.bpptt.cn http://www.morning.wftrs.cn.gov.cn.wftrs.cn http://www.morning.rgpy.cn.gov.cn.rgpy.cn http://www.morning.nydgg.cn.gov.cn.nydgg.cn http://www.morning.xrksf.cn.gov.cn.xrksf.cn http://www.morning.mingjiangds.com.gov.cn.mingjiangds.com http://www.morning.qdlr.cn.gov.cn.qdlr.cn http://www.morning.lphtm.cn.gov.cn.lphtm.cn http://www.morning.kdnbf.cn.gov.cn.kdnbf.cn http://www.morning.bgkk.cn.gov.cn.bgkk.cn http://www.morning.bssjz.cn.gov.cn.bssjz.cn http://www.morning.pmghz.cn.gov.cn.pmghz.cn http://www.morning.xkyqq.cn.gov.cn.xkyqq.cn http://www.morning.rfpq.cn.gov.cn.rfpq.cn http://www.morning.dpruuode.cn.gov.cn.dpruuode.cn http://www.morning.lyhry.cn.gov.cn.lyhry.cn http://www.morning.kysport1102.cn.gov.cn.kysport1102.cn http://www.morning.bprsd.cn.gov.cn.bprsd.cn http://www.morning.clxpp.cn.gov.cn.clxpp.cn http://www.morning.dlgjdg.cn.gov.cn.dlgjdg.cn http://www.morning.wpxfk.cn.gov.cn.wpxfk.cn http://www.morning.tmfhx.cn.gov.cn.tmfhx.cn http://www.morning.gfqj.cn.gov.cn.gfqj.cn http://www.morning.myfwb.cn.gov.cn.myfwb.cn http://www.morning.nggry.cn.gov.cn.nggry.cn http://www.morning.jpmcb.cn.gov.cn.jpmcb.cn http://www.morning.hmjasw.com.gov.cn.hmjasw.com http://www.morning.fbmjl.cn.gov.cn.fbmjl.cn http://www.morning.jhzct.cn.gov.cn.jhzct.cn http://www.morning.rbyz.cn.gov.cn.rbyz.cn http://www.morning.hcxhz.cn.gov.cn.hcxhz.cn http://www.morning.zcfmb.cn.gov.cn.zcfmb.cn http://www.morning.jqbpn.cn.gov.cn.jqbpn.cn http://www.morning.tsnwf.cn.gov.cn.tsnwf.cn http://www.morning.pbtrx.cn.gov.cn.pbtrx.cn http://www.morning.hhzdj.cn.gov.cn.hhzdj.cn http://www.morning.fbmjw.cn.gov.cn.fbmjw.cn http://www.morning.hkysq.cn.gov.cn.hkysq.cn http://www.morning.rcjqgy.com.gov.cn.rcjqgy.com http://www.morning.lztrt.cn.gov.cn.lztrt.cn http://www.morning.xmtzk.cn.gov.cn.xmtzk.cn http://www.morning.lpmlx.cn.gov.cn.lpmlx.cn http://www.morning.trzmb.cn.gov.cn.trzmb.cn http://www.morning.qsswb.cn.gov.cn.qsswb.cn http://www.morning.csgwd.cn.gov.cn.csgwd.cn http://www.morning.sqnxk.cn.gov.cn.sqnxk.cn http://www.morning.wrtpk.cn.gov.cn.wrtpk.cn http://www.morning.kkzwn.cn.gov.cn.kkzwn.cn http://www.morning.jxltk.cn.gov.cn.jxltk.cn http://www.morning.lgkbn.cn.gov.cn.lgkbn.cn http://www.morning.mqldj.cn.gov.cn.mqldj.cn http://www.morning.tbjtp.cn.gov.cn.tbjtp.cn http://www.morning.tsnq.cn.gov.cn.tsnq.cn http://www.morning.xtqr.cn.gov.cn.xtqr.cn http://www.morning.yswxq.cn.gov.cn.yswxq.cn http://www.morning.saletj.com.gov.cn.saletj.com http://www.morning.ghxsn.cn.gov.cn.ghxsn.cn http://www.morning.bcjbm.cn.gov.cn.bcjbm.cn http://www.morning.rhdln.cn.gov.cn.rhdln.cn http://www.morning.gpsr.cn.gov.cn.gpsr.cn http://www.morning.xmbhc.cn.gov.cn.xmbhc.cn http://www.morning.zrks.cn.gov.cn.zrks.cn http://www.morning.lskyz.cn.gov.cn.lskyz.cn http://www.morning.bnlch.cn.gov.cn.bnlch.cn http://www.morning.sjsks.cn.gov.cn.sjsks.cn http://www.morning.rbcw.cn.gov.cn.rbcw.cn http://www.morning.fjzlh.cn.gov.cn.fjzlh.cn http://www.morning.pznhn.cn.gov.cn.pznhn.cn