15

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.

Community
  • 1
  • 1
simmons
  • 835
  • 1
  • 9
  • 17

4 Answers4

24

The following still works (October 2019)

brew install poppler
Vishal
  • 2,097
  • 6
  • 27
  • 45
2

Installing Homebrew and pasting the receipe for poppler in terminal worked for me. OS-x sierra

Nico Vink
  • 21
  • 8
1

Short Answer

Use conda:

conda install poppler

Longer Answer

In my experience, conda is the best solution for installing Python packages which have external (non-Python) dependencies. There are two options for installing conda, either the full Anaconda distribution or the minimalist Miniconda utility. I prefer Miniconda, which can be installed by running a Bash script, found here:

Miniconda Mac OSX Installers

After installing Miniconda, you typically create a new environment and then activate it, e.g.:

conda create --name py37 python=3.7
conda activate py37

Then you can install packages within the active Conda environment using conda e.g. to install poppler:

conda install poppler

You can also install packages using pip, e.g. to install pdftotext - a package which depends on poppler:

pip install pdftotext
igal
  • 646
  • 7
  • 17
  • 1
    `conda install poppler` completes normally on my WSL2 Ubuntu 20.04 as if it had succeeded. But then I get `ModuleNotFoundError: No module named 'poppler'` when I try to `import poppler` – Homero Esmeraldo May 19 '22 at 23:00
0

Installing in pycharm/setting/interpreter/available packages works for me(2021-08), so maybe installing in Anaconda package management also works, but I didn't try the latter one.