简体   繁体   English

如何安装python-poppler

[英]How to install python-poppler

I downloaded poppler from https://github.com/oschwartz10612/poppler-windows/releases/tag/v21.03.0 and tried to install it with pip install python-poppler in Command Prompt.我从https://github.com/oschwartz10612/poppler-windows/releases/tag/v21.03.0下载了poppler并尝试在命令提示符下使用pip install python-poppler安装它。 It caught error:它捕获了错误:

  Running setup.py clean for python-poppler
Failed to build python-poppler
Installing collected packages: python-poppler
    Running setup.py install for python-poppler ... error

I have extracted the python poppler zip file and put it in the current path, however click on the folder doesn't get it to install, how do I install it?我已经解压了 python poppler zip 文件并将其放在当前路径中,但是单击文件夹并没有安装它,我该如何安装它? The folder looks like below:该文件夹如下所示:

在此处输入图片说明


Edit:编辑:

I tried running我试过跑步

import pdf2image
from pdf2image import convert_from_path

and it caught error:它捕获了错误:

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
C:\Python38\lib\site-packages\pdf2image\pdf2image.py in pdfinfo_from_path(pdf_path, userpw, poppler_path, rawdates, timeout)
    457             env["LD_LIBRARY_PATH"] = poppler_path + ":" + env.get("LD_LIBRARY_PATH", "")
--> 458         proc = Popen(command, env=env, stdout=PIPE, stderr=PIPE)
    459 

C:\Python38\lib\subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text)
    853 
--> 854             self._execute_child(args, executable, preexec_fn, close_fds,
    855                                 pass_fds, cwd, env,

C:\Python38\lib\subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session)
   1306             try:
-> 1307                 hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
   1308                                          # no special security

FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

PDFInfoNotInstalledError                  Traceback (most recent call last)
<ipython-input-16-6d2671d2842e> in <module>
      6 
      7 pdfs = r"C:\Users\Uset\Desktop\pdf_test_file.pdf"
----> 8 pages = convert_from_path(pdfs, 350)
      9 
     10 i = 1

C:\Python38\lib\site-packages\pdf2image\pdf2image.py in convert_from_path(pdf_path, dpi, output_folder, first_page, last_page, fmt, jpegopt, thread_count, userpw, use_cropbox, strict, transparent, single_file, output_file, poppler_path, grayscale, size, paths_only, use_pdftocairo, timeout, hide_annotations)
     96         poppler_path = poppler_path.as_posix()
     97 
---> 98     page_count = pdfinfo_from_path(pdf_path, userpw, poppler_path=poppler_path)["Pages"]
     99 
    100     # We start by getting the output format, the buffer processing function and if we need pdftocairo

C:\Python38\lib\site-packages\pdf2image\pdf2image.py in pdfinfo_from_path(pdf_path, userpw, poppler_path, rawdates, timeout)
    482 
    483     except OSError:
--> 484         raise PDFInfoNotInstalledError(
    485             "Unable to get page count. Is poppler installed and in PATH?"
    486         )

PDFInfoNotInstalledError: Unable to get page count. Is poppler installed and in PATH?

This might help you:这可能会帮助您:

os.environ["PATH"] = r"{'path'}\poppler-21.11.0\Library\bin"

Include this line by replacing the path in your code.通过替换代码中的路径来包含此行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM