pdfをdocxに変換するオープンソースPython ライブラリ「pdf2docx」のインストール

スポンサーリンク

pdfをdocxに変換するオープンソースPython ライブラリ「pdf2docx」のインストールについて解説しています。

「pdf2docx(https://github.com/dothinking/pdf2docx)」は、PDFからテキスト、画像、図面などのデータを抽出し、セクション、段落、画像、表などのルールを使用したレイアウトの解析を行うことができるライブラリです。

■Python

今回のPythonのバージョンは、「3.10.9」を使用しています。(Windows11)(pythonランチャーでの確認)

■pdf2docxをインストールする

pdf2docxをインストールを行いますが、今回はpipを経由してインストールを行うので、まずWindowsのコマンドプロンプトを起動します。

pip install pdf2docx

起動後、上記のコマンドを入力し、Enterキーを押します。

なお、今回は、pythonランチャーを使用しており、Python Version 3.10.9にインストールを行うために、バージョンの切り替えを行います。

py -3.10 -m pip install pdf2docx

切り替えるために、上記のコマンドを入力し、Enterキーを押します。

Defaulting to user installation because normal site-packages is not writeable
Collecting pdf2docx
Downloading pdf2docx-0.5.6-py3-none-any.whl (148 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 148.4/148.4 kB 2.9 MB/s eta 0:00:00
Collecting fonttools>=4.24.0
Downloading fonttools-4.39.4-py3-none-any.whl (1.0 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.0/1.0 MB 2.9 MB/s eta 0:00:00
Collecting fire>=0.3.0
Downloading fire-0.5.0.tar.gz (88 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 88.3/88.3 kB 5.2 MB/s eta 0:00:00
Preparing metadata (setup.py) ... done
Collecting opencv-python>=4.5
Downloading opencv_python-4.7.0.72-cp37-abi3-win_amd64.whl (38.2 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 38.2/38.2 MB 7.9 MB/s eta 0:00:00
Collecting numpy>=1.17.2
Using cached numpy-1.24.3-cp310-cp310-win_amd64.whl (14.8 MB)
Collecting python-docx>=0.8.10
Downloading python-docx-0.8.11.tar.gz (5.6 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.6/5.6 MB 7.0 MB/s eta 0:00:00
Preparing metadata (setup.py) ... done
Collecting PyMuPDF>=1.19.0
Downloading PyMuPDF-1.22.3-cp310-cp310-win_amd64.whl (11.7 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 11.7/11.7 MB 2.8 MB/s eta 0:00:00
Collecting six
Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting termcolor
Downloading termcolor-2.3.0-py3-none-any.whl (6.9 kB)
Collecting lxml>=2.3.2
Using cached lxml-4.9.2-cp310-cp310-win_amd64.whl (3.8 MB)
Installing collected packages: termcolor, six, PyMuPDF, numpy, lxml, fonttools, python-docx, opencv-python, fire, pdf2docx
WARNING: The script f2py.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python310\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The scripts fonttools.exe, pyftmerge.exe, pyftsubset.exe and ttx.exe are installed in 'C:\Users\user_\AppData\Roaming\Python\Python310\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
DEPRECATION: python-docx is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
Running setup.py install for python-docx ... done
DEPRECATION: fire is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
Running setup.py install for fire ... done
WARNING: The script pdf2docx.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python310\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed PyMuPDF-1.22.3 fire-0.5.0 fonttools-4.39.4 lxml-4.9.2 numpy-1.24.3 opencv-python-4.7.0.72 pdf2docx-0.5.6 python-docx-0.8.11 six-1.16.0 termcolor-2.3.0

Enterキーを押すと、インストールが開始され、上記のように「Successfully installed」と表示されます。これが表示されれば、pdf2docxが正常にインストールされたことになります。今回は「WARNING(警告)」が表示されましたが、あくまで警告でありエラーではないので、無視しています。

なお、今回はpdf2docxのバージョン0.5.6をインストールしました。

コメント

タイトルとURLをコピーしました