Install Poppler for Python on Mac

simmons picture simmons · Aug 24, 2015 · Viewed 9.3k times · Source

I need to extract pdf annotations in Python. All my searches indicate I need Poppler to do this e.g. to run this

But I am having a lot of trouble installing Poppler. I'm using Python 3.4 on OS X (Yosemite). Here's what I've tried so far:
1. pip

pip3 install python-poppler-qt4

which gives

ImportError: No module named 'sipdistutils'

2. Next I tried

pip3 install pypoppler

And got

NameError: name 'file' is not defined

3. Next I tried downloading from here Same error as 1. I searched for sipdistutils and found this which I thought might be it. I copied it to the folder and tried pip again. This time I got

File "/python-poppler-qt4-0.24.0/sipdistutils.py", line 32
raise RuntimeError, "cannot parse SIP-generated '%s'" % sbf

4. Next I tried downloading from here and building using ./configure, which gave:

checking for PYPOPPLER... configure: error: Package requirements (                          pygtk-2.0 >= 2.10.0,
                     atk >= 1.6.0,
                     poppler-glib >= 0.12
                     ) were not met:

No package 'pygtk-2.0' found
No package 'atk' found
No package 'poppler-glib' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you 
installed software in a non-standard prefix.   

5. Macports

sudo port install py34-poppler-qt4

Error: Failed to install poppler
Please see the log file for port poppler for details:
        /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_graphics_poppler/poppler/main.log

Error: The following dependencies were not installed: poppler-qt4-mac poppler qt4-mac dbus libmng lcms py34-pyqt4 dbus-python34 dbus-glib python34 python3_select py34-sip

I feel I am very close with several of these approaches - and that something very small would sort this out.

Answer

Vishal picture Vishal · Oct 12, 2019

The following still works (October 2019)

brew install poppler