webmaster-kazu.com

テクノロジー・データ分析・実践ログ・その他

【Python】PDF文書から情報を抽出する「pdfminer.six」のインストール

カテゴリ: Python【初歩から現場実務的なもの】

PDF文書から情報を抽出する「pdfminer.six」のインストールについて解説しています。

「pdfminer.six(https://github.com/pdfminer/pdfminer.six)」は、PDF文書のテキスト データの取得と分析に重点を置いた情報を抽出するツールです。

■Python

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

■pdfminer.sixをインストールする

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

pip install pdfminer.six

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

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

py -3.9 -m pip install pdfminer.six

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

Defaulting to user installation because normal site-packages is not writeable

Collecting pdfminer.six

Downloading pdfminer.six-20221105-py3-none-any.whl (5.6 MB)

|████████████████████████████████| 5.6 MB 1.7 MB/s

Requirement already satisfied: charset-normalizer>=2.0.0 in c:\users\user_\appdata\roaming\python\python39\site-packages (from pdfminer.six) (3.2.0)

Collecting cryptography>=36.0.0

Downloading cryptography-41.0.3-cp37-abi3-win_amd64.whl (2.6 MB)

|████████████████████████████████| 2.6 MB 89 kB/s

Collecting cffi>=1.12

Using cached cffi-1.15.1-cp39-cp39-win_amd64.whl (179 kB)

Collecting pycparser

Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB)

Installing collected packages: pycparser, cffi, cryptography, pdfminer.six

Successfully installed cffi-1.15.1 cryptography-41.0.3 pdfminer.six-20221105 pycparser-2.21

WARNING: You are using pip version 21.2.4; however, version 23.2.1 is available.

You should consider upgrading via the 'C:\Program Files\Python39\python.exe -m pip install --upgrade pip' command.

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

なお、今回はpdfminer.sixのバージョン20221105をインストールしました。