Mac OS 11.4でpip pdftotext

M1Macで何故か素直に入らなかったのでメモ

環境

  • M1 Mac book Air
  • OS: 11.4
  • python: Intel miniconda3
  • python version:3.8.5

手順

brewでPdftotextを入れる

brew install pdftotext

~/.zshrcに追加

export C_INCLUDE_PATH=/opt/homebrew/Cellar/poppler/21.05.0/include:$C_INCLUDE_PATH
export CPATH=$C_INCLUDE_PATH
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/opt/homebrew/Cellar/poppler/21.05.0/lib # どうもこれは効かないらしい

pipでpdftotextライブラリを入れる 

pip install pdftotext --global-option=build_ext --global-option="-L/opt/homebrew/Cellar/poppler/21.05.0/lib"