webmaster-kazu.com

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

docx形式のファイルをHTMLに変換できるライブラリ「mammoth」をインストールする

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

docx形式のファイルをHTMLに変換できるライブラリ「mammoth」のインストールについて解説しています。

mammothは、Microsoft WordやGoogle Docs、LibreOfficeなどで作成された.docx形式の文書(ドキュメント)をHTMLに変換することができます。

■Python

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

■mammothをインストールする

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

pip install mammoth

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

なお、今回は、pythonランチャーを使用しており、Python Version 3.8.5にインストールを行うために、pipを使う場合にはコマンドでの切り替えを行います。

py -3.8 -m pip install mammoth

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

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

Collecting mammoth

Downloading mammoth-1.4.16-py2.py3-none-any.whl (51 kB)

|████████████████████████████████| 51 kB 18 kB/s

Collecting cobble<0.2,>=0.1.3

Downloading cobble-0.1.3.tar.gz (11 kB)

Using legacy setup.py install for cobble, since package 'wheel' is not installed.

Installing collected packages: cobble, mammoth

Running setup.py install for cobble ... done

Successfully installed cobble-0.1.3 mammoth-1.4.16

Enterキーを押すと、インストールが開始され、上記のように「Successfully installed」と表示されます。これが表示されれば、mammothが正常にインストールされたことになります。

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