[英]Install Poppler for Python on Mac
I need to extract pdf annotations in Python.我需要在 Python 中提取 pdf 注释。 All my searches indicate I need Poppler to do this eg to run this
我所有的搜索都表明我需要 Poppler 来执行此操作,例如运行此操作
But I am having a lot of trouble installing Poppler.但是我在安装 Poppler 时遇到了很多麻烦。 I'm using Python 3.4 on OS X (Yosemite).
我在 OS X (Yosemite) 上使用 Python 3.4。 Here's what I've tried so far:
这是我迄今为止尝试过的:
1. pip 1. 点子
pip3 install python-poppler-qt4
which gives这使
ImportError: No module named 'sipdistutils'
2. Next I tried 2.接下来我尝试
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. 3.接下来,我试图从网上下载这里为1。我搜索sipdistutils,发现同样的错误这个我觉得可能是吧。 I copied it to the folder and tried pip again.
我将它复制到文件夹并再次尝试 pip 。 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: 4. 接下来我尝试从这里下载并使用 ./configure 构建,它给出:
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 5. 麦克波特
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错误:未安装以下依赖项: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.我觉得我非常接近这些方法中的几种 - 并且非常小的东西可以解决这个问题。
以下仍然有效(2019 年 10 月)
brew install poppler
Installing Homebrew and pasting the receipe for poppler in terminal worked for me.安装 Homebrew 并在终端中粘贴 poppler 的收据对我有用。 OS-x sierra
OS-x 山脉
Use conda:使用康达:
conda install poppler
In my experience, conda
is the best solution for installing Python packages which have external (non-Python) dependencies.根据我的经验,
conda
是安装具有外部(非 Python)依赖项的 Python 包的最佳解决方案。 There are two options for installing conda, either the full Anaconda distribution or the minimalist Miniconda utility.有两种安装 conda 的选项,完整的 Anaconda 发行版或极简的 Miniconda 实用程序。 I prefer Miniconda, which can be installed by running a Bash script, found here:
我更喜欢 Miniconda,它可以通过运行 Bash 脚本来安装,可以在这里找到:
Miniconda Mac OSX Installers Miniconda Mac OSX 安装程序
After installing Miniconda, you typically create a new environment and then activate it, eg:安装 Miniconda 后,您通常会创建一个新环境然后激活它,例如:
conda create --name py37 python=3.7
conda activate py37
Then you can install packages within the active Conda environment using conda
eg to install poppler
:然后您可以使用
conda
在活动的 Conda 环境中安装软件包,例如安装poppler
:
conda install poppler
You can also install packages using pip
, eg to install pdftotext
- a package which depends on poppler
:您还可以使用
pip
安装软件包,例如安装pdftotext
- 一个依赖于poppler
的软件包:
pip install pdftotext
在 pycharm/setting/interpreter/available 包中安装对我有用(2021-08),所以也许在 Anaconda 包管理中安装也有效,但我没有尝试后一个。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.