Install Poppler for Python on Mac
Asked Answered
C

3

17

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.

Condemnatory answered 24/8, 2015 at 7:48 Comment(2)
Homebrew (which for me has always worked much better than Macports) has a recipe for Poppler.Goings
macappstore.org/popplerOf
I
27

The following still works (October 2019)

brew install poppler
Ionosphere answered 12/10, 2019 at 15:50 Comment(0)
C
2

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

Chanterelle answered 17/4, 2017 at 6:14 Comment(0)
D
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
Dibb answered 8/1, 2021 at 14:50 Comment(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 popplerJaneanjaneczka

© 2022 - 2024 — McMap. All rights reserved.