English 中文(简体)
利用Windows上的Python-poppler-qt5
原标题:Using python-poppler-qt5 on Windows

Using python-poppler-qt5 on Windows I am working on a project that involves qpageview, which is a library that extends PyQt5, and depends on python-poppler-qt5, the Python bindings for poppler-qt5. Poppler is a C++ library which easy to use on Linux, but difficult to use on Windows. A quick web search will indicate that many people have made various distributions for poppler on Windows, but unfortunately, none of these solve my problem. I have tried various environments on Windows, including MSYS, Cygwin, Anaconda, and the default Windows Python distribution with the MS Build Tools, and I believe that the furthest I have got is to use Cygwin, so this post will focus on that approach. I am just looking for someone to help point me in the right direction to getting this to work, as I have experience with Python, but much less with C/C++. This works fine in WSL, but I would like to make it work Windows natively too. First, to ensure that my various previous attempts will not cause problems, I created an entirely new Windows 10 installation in VirtualBox. Inside of VirtualBox, I only installed Cygwin (and Git Bash, so I could clone my repository to get my code in the virtual machine). Over the course of my various attempts, I have installed many packages to ensure that all the dependencies are installed in my Cygwin distribution. When I open up the Cygwin terminal, I use git to clone the repository. My minimal reproducible example program to run to prove qpageview works. This works fine in Ubuntu Linux on WSL:

from PyQt5.QtWidgets import QApplication
import qpageview

app = QApplication([])

v = qpageview.View()
v.resize(900, 500)
v.show()
v.loadPdf("../pyqt.pdf")
app.exec()

我安装了Cygwin包裹:https://pastebin.com/bL13jqic

关于我的热带气候环境的其他信息:

me@system ~/python-poppler-qt5
$ pip freeze #this is run within cygwin, but outside of any virtual environment
Babel @ file:///pub/devel/python/python-babel/python-babel-2.12.1-1.noarch/build/dist/Babel-2.12.1-py3-none-any.whl
cffi @ file:///pub/devel/python/python-cffi/python-cffi-1.15.1-1.x86_64/build/dist/cffi-1.15.1-cp39-cp39-cygwin_3_4_6_x86_64.whl
chardet @ file:///pub/devel/python/python-chardet/python-chardet-4.0.0-2.noarch/build/dist/chardet-4.0.0-py2.py3-none-any.whl
Cython @ file:///pub/devel/python/python-cython/python-cython-0.29.33-1.x86_64/build/dist/Cython-0.29.33-cp39-cp39-cygwin_3_4_6_x86_64.whl
dbus-python @ file:///pub/devel/python/python-dbus/python-dbus-1.2.18-1.x86_64/build/dist/dbus_python-1.2.18-cp39-cp39-cygwin_3_3_3_x86_64.whl
distlib @ file:///pub/devel/python/python-distlib/python-distlib-0.3.6-1.noarch/build/dist/distlib-0.3.6-py2.py3-none-any.whl
docutils @ file:///pub/devel/python/python-docutils/python-docutils-0.18.1-1.noarch/build/dist/docutils-0.18.1-py2.py3-none-any.whl
filelock @ file:///pub/devel/python/python-filelock/python-filelock-3.9.0-1.noarch/build/dist/filelock-3.9.0-py3-none-any.whl
idna @ file:///pub/devel/python/python-idna/python-idna-3.3-1.noarch/build/dist/idna-3.3-py3-none-any.whl
imagesize @ file:///pub/devel/python/python-imagesize/python-imagesize-1.3.0-1.noarch/build/dist/imagesize-1.3.0-py2.py3-none-any.whl
iniconfig @ file:///pub/devel/python/python-iniconfig/python-iniconfig-2.0.0-1.noarch/build/dist/iniconfig-2.0.0-py3-none-any.whl
Jinja2 @ file:///pub/devel/python/python-jinja2/python-jinja2-3.1.2-1.noarch/build/dist/Jinja2-3.1.2-py3-none-any.whl
MarkupSafe @ file:///pub/devel/python/python-markupsafe/python-markupsafe-2.1.2-1.x86_64/build/dist/MarkupSafe-2.1.2-cp39-cp39-cygwin_3_4_6_x86_64.whl
olefile @ file:///pub/devel/python/python-olefile/python-olefile-0.46-3.noarch/build/dist/olefile-0.46-py2.py3-none-any.whl
packaging @ file:///pub/devel/python/python-packaging/python-packaging-21.3-1.noarch/build/dist/packaging-21.3-py3-none-any.whl
Pillow @ file:///home/Hamis/python-imaging/python-imaging-8.4.0-1.x86_64/build/dist/Pillow-8.4.0-cp39-cp39-cygwin_3_3_3_x86_64.whl
platformdirs @ file:///pub/devel/python/python-platformdirs/python-platformdirs-3.1.1-1.noarch/build/dist/platformdirs-3.1.1-py3-none-any.whl
pluggy @ file:///pub/devel/python/python-pluggy/python-pluggy-1.0.0-1.noarch/build/dist/pluggy-1.0.0-py2.py3-none-any.whl
ply==3.11
pycairo @ file:///pub/devel/python/python-cairo/python-cairo-1.20.1-1.x86_64/build/dist/pycairo-1.20.1-cp39-cp39-cygwin_3_3_3_x86_64.whl
pycparser @ file:///pub/devel/python/python-pycparser/python-pycparser-2.21-1.noarch/build/dist/pycparser-2.21-py2.py3-none-any.whl
PyCygwin==0.1
Pygments @ file:///pub/devel/python/python-pygments/python-pygments-2.10.0-1.noarch/build/dist/Pygments-2.10.0-py3-none-any.whl
PyGObject @ file:///cygdrive/d/a/scallywag/python-gi/python-gi-3.36.1-3.x86_64/build/dist/PyGObject-3.36.1-cp39-cp39-cygwin_3_4_5_x86_64.whl
pyparsing @ file:///pub/devel/python/python-pyparsing/python-pyparsing-3.0.6-1.noarch/build/dist/pyparsing-3.0.6-py3-none-any.whl
PyQt-builder==1.15.1
PyQt5==5.15.6
pytest @ file:///pub/devel/python/python-pytest/python-pytest-7.3.0-1.noarch/build/dist/pytest-7.3.0-py3-none-any.whl
requests @ file:///pub/devel/python/python-requests/python-requests-2.27.1-1.noarch/build/dist/requests-2.27.1-py2.py3-none-any.whl
sip==6.7.9
six @ file:///pub/devel/python/python-six/python-six-1.16.0-1.noarch/build/dist/six-1.16.0-py2.py3-none-any.whl
snowballstemmer @ file:///pub/devel/python/python-snowballstemmer/python-snowballstemmer-2.2.0-1.noarch/build/dist/snowballstemmer-2.2.0-py2.py3-none-any.whl
Sphinx @ file:///pub/devel/python/python-sphinx/python-sphinx-4.4.0-1.noarch/build/dist/Sphinx-4.4.0-py3-none-any.whl
sphinxcontrib-serializinghtml @ file:///pub/devel/python/python-sphinxcontrib-serializinghtml/python-sphinxcontrib-serializinghtml-1.1.5-1.noarch/build/dist/sphinxcontrib_serializinghtml-1.1.5-py2.py3-none-any.whl
toml @ file:///pub/devel/python/python-toml/python-toml-0.10.2-2.noarch/build/dist/toml-0.10.2-py2.py3-none-any.whl
tomli==2.0.1
urllib3 @ file:///pub/devel/python/python-urllib3/python-urllib3-1.26.7-1.noarch/build/dist/urllib3-1.26.7-py2.py3-none-any.whl
virtualenv @ file:///pub/devel/python/python-virtualenv/python-virtualenv-20.21.0-1.noarch/build/dist/virtualenv-20.21.0-py3-none-any.whl

me@system ~/python-poppler-qt5
$ which gcc
/usr/bin/gcc

me@system ~/python-poppler-qt5
$ which g++
/usr/bin/g++

me@system ~/python-poppler-qt5
$ which python
/usr/bin/python

me@system ~/python-poppler-qt5
$ which sip-build
/usr/local/bin/sip-build

me@system ~/python-poppler-qt5
$ which sip-install
/usr/local/bin/sip-install

me@system ~/python-poppler-qt5
$ python --version
Python 3.9.16

me@system ~/python-poppler-qt5
$ gcc --version
gcc (GCC) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


me@ system ~/python-poppler-qt5
$ g++ --version
g++ (GCC) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


me@system ~/python-poppler-qt5
$ sip-build --version
6.7.9

me@system ~/python-poppler-qt5
$ sip-install --version
6.7.9

me@system ~/python-poppler-qt5
$ which ld
/usr/bin/ld

me@system ~/python-poppler-qt5
$ ld --version
GNU ld (GNU Binutils) 2.40
Copyright (C) 2023 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.

为了建立这一系统,我仅操作sip-build -verbose。 当你安装了Python-poppler-qt5和Pip时,该指挥系统也投入运作,但是这允许你实际上看到编集器的分解结果。 然而,我对汇编阶段感到困惑,我正在收到大量错误信息,似乎表明与某种“灰色”和“C++”兼容图书馆有联系。 例如,其中第5条说:

/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: sippopplerqt5cmodule.o:sippopplerqt5cmodule.cpp:(.text+0x296): undefined reference to `Py_BuildValue 
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: sippopplerqt5cmodule.o:sippopplerqt5cmodule.cpp:(.text+0x306): undefined reference to `Py_BuildValue 
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: sippopplerqt5cmodule.o:sippopplerqt5cmodule.cpp:(.text+0x1ad9): undefined reference to `PyModule_Create2 
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: sippopplerqt5cmodule.o:sippopplerqt5cmodule.cpp:(.text+0x1aed): undefined reference to `PyModule_GetDict 
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: sippopplerqt5cmodule.o:sippopplerqt5cmodule.cpp:(.text+0x1afc): undefined reference to `PyImport_ImportModule 

我不知道如何纠正这种情况,我期待着看到有人能够帮助我正确指明方向。 你能够补充的是有用的。 感谢!

更新:建筑文字似乎排除了必要的加++编造旗——lpython3.9。 问题在于如何适当补充,因为项目似乎自动产生文件。

问题回答

暂无回答




相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签