[英]How to install poppler and setup pdf2image on elastic beanstalk
[英]Mac Poppler + pdf2image PATH bug
问题:我一直在尝试使用 Python 库 pdf2image,我知道它需要事先安装 poppler。 Poppler 已安装(通过自制软件),package 通过 pip 安装。
但是,在运行convert_to_path(my_pdf)
时,我得到以下信息:
Traceback (most recent call last):
File "<ipython-input-9-ba107659b495>", line 1, in <module>
test_image = convert_from_path(testfile,
File "/Users/<myuser>/.pyenv/versions/3.8.0/lib/python3.8/site-packages/pdf2image/pdf2image.py", line 97, in convert_from_path
page_count = pdfinfo_from_path(pdf_path, userpw, poppler_path=poppler_path)["Pages"]
File "/Users/<myuser>/.pyenv/versions/3.8.0/lib/python3.8/site-packages/pdf2image/pdf2image.py", line 467, in pdfinfo_from_path
raise PDFInfoNotInstalledError(
PDFInfoNotInstalledError: Unable to get page count. Is poppler installed and in PATH?
我的系统:Mac,OC 10.15.7 Python(通过 Homebrew)版本 3.8.0
which python
/Users/<myuser>/.pyenv/shims/python
which pip
/Users/<myuser>/.pyenv/shims/pip
到目前为止我已经尝试过: Poppler 是通过自制软件安装的( brew install poppler
)和 pdf2image 安装pip3 install pdf2image
我也运行了brew cleanup
。
尝试使用以下内容在 convert_to_path 中强制使用 poppler 路径,
pop_path = "/usr/local/Cellar/poppler/21.03.0_1"
convert_to_path(my_pdf_file,poppler_path = pop_path)
但仍然出现相同的错误。
上网查了一下,发现很多人都有类似但不完全相同的问题。 我觉得我一定做错了什么,所以任何指导都会很棒。
部分解决方案?
在手动输入pop_path文件路径时,忘记把append /bin到路径,
pop_path = "/usr/local/Cellar/poppler/21.03.0_1/bin"
该代码现在有效。 虽然我的自尊需要一段时间才能恢复...
我觉得我可能仍然坐在一个糟糕的配置问题上? 关于类似问题的许多帖子似乎暗示自制软件安装的popper不应该有这个问题。 可能是因为我也在使用 pyenv 吗?
如果您使用 conda 环境,请在 mac 终端中运行以下代码
conda install -c conda-forge pdf2image
conda install -c conda-forge poppler
它解决了问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.