LoginSignup
1
0

More than 5 years have passed since last update.

MacOSX(10.11.xx)にPythonライブラリTRML2PDFを導入する

Last updated at Posted at 2016-12-02

PythonでPDF生成をするライブラリであるTRML2PDFの導入で少しつまずいたのでメモ。

環境:
MacOSX(10.11.6 El Capitane)
Python2.7.x(都合によりpyenv環境)

pip及びhomebrew導入済み

最終的にやったこと

# jpegを扱うライブラリ
brew install jpeg

# Pythonの画像処理ライブラリ
pip install pillow

# PythonのPDF生成ライブラリ
pip install trml2pdf

でOKです。

TRML2PDFのインストール

以下を参照。
TRML2PDF
https://github.com/romanlv/trml2pdf/

READMEに書いてある通り、

pip install trml2pdf

としたら、

ValueError: jpeg is required unless explicitly disabled using --disable-jpeg, aborting

となってしまった。明示的にjpegをdisableなオプションを付けろとのこと。
もう少し読むと、TRML2PDFを使うには、Pillowというライブラリが必要なのでそれをインストールしている最中にエラーが起きている。

Pillowのインストール

pip install pillow
...
ValueError: jpeg is required unless explicitly disabled using --disable-jpeg, aborting

Pillowのインストール中にエラー起きてるのだから、当たり前のように同じエラーが出る。ともあれやはりPillowのインストールが失敗していることが原因であることはわかりました。

調べるとPillowでjpegを扱おうとする時はlibjpegというjpegのエンコード・デコードを行うライブラリが必要とのこと。ほう。
https://ja.wikipedia.org/wiki/Libjpeg

homebrewでlibjepgをインストール

brew install jpeg

再度pipでPillowをインストール

pip install pillow

再度pipでTRML2PDFをインストール

pip install trml2pdf

インタープリタからでよいのでインポートしてみましょう。

python

Python 2.7.2 (default, Nov 25 2016, 09:30:37) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

>>> import trml2pdf
>>>

よさそうですね!

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0