【问题标题】:Include poppler while generating an application using pyinstaller使用 pyinstaller 生成应用程序时包含 poppler
【发布时间】:2020-12-14 06:15:06
【问题描述】:

我正在使用 poppler 阅读 pdfs

Poppler 文件夹位于我的源文件中,如下所示。 代码如下:

    pages = convert_from_path(pdf_file,500,poppler_path = r'.\\poppler\\bin',
                              first_page=pageNo[0],last_page =pageNo[len(pageNo)-1] )

我想使用 pyinstaller 为我的 python 应用程序生成 exe。 但是我将它们包含在 pyinstaller 命令中。它似乎不起作用。

我收到以下错误: 异常 无法获取页数。 poppler 是否已安装并在 PATH 中?创建数据库数据帧时发生

以下是我尝试在我的 pyinstaller 命令中包含 poppler 的方法:

pyinstaller --noconfirm --onefile --windowed --add-data --add-data "C:/Users/projectPath/poppler/*;./poppler" "C:/Users/projectPath/AutoUpdate.py "

pyinstaller --noconfirm --onefile --windowed --add-data --add-data "C:/Users/projectPath/poppler;./poppler" "C:/Users/projectPath/AutoUpdate.py"

pyinstaller --noconfirm --onefile --windowed --add-data --add-data "C:/Users/projectPath/poppler;poppler/" "C:/Users/projectPath/AutoUpdate.py"

【问题讨论】:

    标签: python pyinstaller poppler


    【解决方案1】:

    开始使用 onedir 方法而不是 onefile。现在可以正常工作。

    以下是更新后的 pyinstaller 命令:

    pyinstaller --noconfirm --onedir --windowed --add-data --add-data "C:/Users/projectPath/poppler/*;./poppler" "C:/Users/projectPath/AutoUpdate.py"
    

    【讨论】:

    • 您确定是因为--onefile 选项吗?更改为 --onedir 并不能解决我的问题。
    • 您的poppler/ 目录中有什么?二进制文件?我使用位于 Anaconda 的 env 目录中的 conda install -c conda-forge popplerpoppler 安装了 poppler。
    猜你喜欢
    • 2017-05-21
    • 2019-11-02
    • 2017-12-11
    • 1970-01-01
    • 2020-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-13
    相关资源
    最近更新 更多