Web開発者がPDFドキュメントを作成するのに役立つ「weasyprint」のインストール

スポンサーリンク

Web開発者がPDFドキュメントを作成するのに役立つPythonの「weasyprint」のインストールについて解説しています。

「weasyprint(https://doc.courtbouillon.org/weasyprint/stable/)」PDFにエクスポートできるHTMLおよびCSS用のビジュアルレンダリングエンジンです。

■Python

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

■weasyprintをインストールする

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

pip install weasyprint

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

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

py -3.8 -m pip install weasyprint

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

Defaulting to user installation because normal site-packages is not writeable
Collecting weasyprint
Downloading weasyprint-54.2-py3-none-any.whl (247 kB)
|████████████████████████████████| 247 kB 819 kB/s
Collecting cssselect2>=0.1
Downloading cssselect2-0.5.0-py3-none-any.whl (15 kB)
Requirement already satisfied: html5lib>=1.1 in c:\users\user_\appdata\roaming\python\python38\site-packages (from weasyprint) (1.1)
Collecting tinycss2>=1.0.0
Downloading tinycss2-1.1.1-py3-none-any.whl (21 kB)
Requirement already satisfied: Pillow>=4.0.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from weasyprint) (8.2.0)
Collecting pydyf>=0.0.3
Downloading pydyf-0.1.2-py3-none-any.whl (6.4 kB)
Collecting fonttools[woff]>=4.0.0
Downloading fonttools-4.30.0-py3-none-any.whl (898 kB)
|████████████████████████████████| 898 kB 1.3 MB/s
Collecting Pyphen>=0.9.1
Downloading pyphen-0.12.0-py3-none-any.whl (2.0 MB)
|████████████████████████████████| 2.0 MB 3.2 MB/s
Requirement already satisfied: cffi>=0.6 in c:\users\user_\appdata\roaming\python\python38\site-packages (from weasyprint) (1.14.5)
Requirement already satisfied: pycparser in c:\users\user_\appdata\roaming\python\python38\site-packages (from cffi>=0.6->weasyprint) (2.20)
Requirement already satisfied: webencodings in c:\users\user_\appdata\roaming\python\python38\site-packages (from cssselect2>=0.1->weasyprint) (0.5.1)
Collecting zopfli>=0.1.4
Downloading zopfli-0.2.1-cp38-cp38-win_amd64.whl (111 kB)
|████████████████████████████████| 111 kB 3.3 MB/s
Requirement already satisfied: brotli>=1.0.1 in c:\users\user_\appdata\roaming\python\python38\site-packages (from fonttools[woff]>=4.0.0->weasyprint) (1.0.9)
Requirement already satisfied: six>=1.9 in c:\users\user_\appdata\roaming\python\python38\site-packages (from html5lib>=1.1->weasyprint) (1.15.0)
Installing collected packages: zopfli, tinycss2, fonttools, Pyphen, pydyf, cssselect2, weasyprint
Successfully installed Pyphen-0.12.0 cssselect2-0.5.0 fonttools-4.30.0 pydyf-0.1.2 tinycss2-1.1.1 weasyprint-54.2 zopfli-0.2.1

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

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

コメント

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