LoginSignup
1
0

More than 1 year has passed since last update.

Open Source PyMOLをMacにインストールする際のfreetypeのトラブル.

Last updated at Posted at 2021-08-16

この記事はなに?

PyMOLをソースコードからインストールしましたので,手間のかかったトラブルとその解決策を記載します.インストールの流れは公式のGitHubのページのInstallationに記載があるのでここでは記載しません.ここで扱うトラブルは,インストール時にfreetypeをうまく読み込めないことです.この記事は,PyMOLインストール時に発生した以下のエラーを解決した際の作業ログです.

$ python3 setup.py install --prefix=~
()
layer1/TypeFace.cpp:25:10: fatal error: 'ft2build.h' file not found
#include <ft2build.h>
         ^~~~~~~~~~~~
1 error generated.

私がPyMOLをインストールした環境は以下の通りです.
端末: MacBook Air (M1, 2020)
OS: macOS Big Sur Version 11.5
Bash: GNU bash, version 3.2.57(1)-release (arm64-apple-darwin20)
python3: Python 3.9.6

解決策

まず,freetypeがインストールされていることを確認します.

$ brew list|grep freetype
freetype

過去の私はfreetypeを既にインストールしたようです.入っていなければbrew install freetypeでインストールする予定でした.

つぎに,freetypeに関連するディレクトリからft2build.hを見つけます.私の環境では以下の場所に見つけました.

$ ls /opt/homebrew/Cellar/freetype/2.11.0/include/freetype2/
freetype        ft2build.h

この場所にあるft2build.hを読み込んでもらうために,PREFIX_PATHを設定します.この設定をするのは,PyMOL wikiに以下の説明があるためです.

Libraries in non-standard places
Optional: You may use the colon-delimited $PREFIX_PATH variable to point setup.py to non-standard locations of libraries and headers (those locations should have include and lib directories).

つまり,今回のようにヘッダーファイルを読み込ませたいときは,PREFIX_PATHにコロン区切りで設定したら良いということです.この説明に従って,次のように変数PREFIX_PATHを設定しました.

$ export PREFIX_PATH=/opt/homebrew/Cellar/freetype/2.11.0/

ここで注意すべきことがあります.ft2build.hへのパスを指定するのではなく,必ずincludeの親ディレクトリまでを指定します.(私はこのことに気づくまで多くの試行錯誤と時間を要しました.)この後再度以下のコマンドを実行することで,インストールすることができました.

$ python3 setup.py install --prefix=~
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