使用自制酒桶安装后,无法将pdftotext导入python

时间:2019-07-10 06:03:17

标签: python anaconda homebrew pdftotext homebrew-cask

我正在尝试开发一个应用程序,该应用程序要求我从PDF中读取文本,因此尝试安装python库pdftotext。我通过anaconda使用Mac OS和python。

我最初尝试使用pip install pdftotext,但是不断遇到类型为“错误:命令'gcc'失败,退出状态为1”的错误。对于Mac OS,我可以看到的唯一依赖性是pkg-config poppler,它是使用自制软件安装的。然后,我找到了使用命令“ brew cask install pdftotext”使用homebrew安装pdftotext的说明。此安装成功,但是当我尝试将其导入笔记本时,它告诉我没有名为pdftotext的模块。

从自制软件导入时出错

Vishals-MacBook-Air:~ vishalpatel$ brew cask install pdftotext
Warning: Cask 'pdftotext' is already installed.

To re-install pdftotext, run:
  brew cask reinstall pdftotext

Vishals-MacBook-Air:~ vishalpatel$ python -c 'import pdftotext'

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'pdftotext'

尝试使用pip install进行安装时出错

Vishals-MacBook-Air:~ vishalpatel$ brew install pkg-config poppler

Warning: pkg-config 0.29.2 is already installed and up-to-date
To reinstall 0.29.2, run `brew reinstall pkg-config`
Warning: poppler 0.77.0 is already installed and up-to-date
To reinstall 0.77.0, run `brew reinstall poppler`

Vishals-MacBook-Air:~ vishalpatel$ pip install pdftotext

Collecting pdftotext
  Using cached https://files.pythonhosted.org/packages/21/35/60094dbadd9de2035873390b1cac25e01da605844eba6a07a53a82fa4adc/pdftotext-2.1.1.tar.gz
Building wheels for collected packages: pdftotext
  Building wheel for pdftotext (setup.py) ... error
  ERROR: Complete output from command /Users/vishalpatel/anaconda3/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/f1/wd32_gd10q58w4bdk8t5f1540000gn/T/pip-install-akx2k4vg/pdftotext/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/f1/wd32_gd10q58w4bdk8t5f1540000gn/T/pip-wheel-_cbu4k4x --python-tag cp36:
  ERROR: running bdist_wheel
  running build
  running build_ext
  building 'pdftotext' extension
  creating build
  creating build/temp.macosx-10.7-x86_64-3.6
  gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/vishalpatel/anaconda3/include -arch x86_64 -I/Users/vishalpatel/anaconda3/include -arch x86_64 -DPOPPLER_CPP_AT_LEAST_0_30_0=1 -I/Users/vishalpatel/anaconda3/include/python3.6m -c pdftotext.cpp -o build/temp.macosx-10.7-x86_64-3.6/pdftotext.o -Wall -mmacosx-version-min=10.9
  cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
  In file included from pdftotext.cpp:5:0:
  /Users/vishalpatel/anaconda3/include/poppler/cpp/poppler-page.h:37:22: error: expected ‘,’ or ‘...’ before ‘&&’ token
       text_box(text_box&&) = default;
                        ^
  /Users/vishalpatel/anaconda3/include/poppler/cpp/poppler-page.h:37:28: error: invalid constructor; you probably meant ‘poppler::text_box (const poppler::text_box&)’
       text_box(text_box&&) = default;
                              ^
  /Users/vishalpatel/anaconda3/include/poppler/cpp/poppler-page.h:38:33: error: expected ‘,’ or ‘...’ before ‘&&’ token
       text_box& operator=(text_box&&) = default;
                                   ^
  /Users/vishalpatel/anaconda3/include/poppler/cpp/poppler-page.h:63:5: error: ‘unique_ptr’ in namespace ‘std’ does not name a type
       std::unique_ptr<text_box_data> m_data;
       ^
  /Users/vishalpatel/anaconda3/include/poppler/cpp/poppler-page.h:38:15: error: defaulted declaration ‘poppler::text_box& poppler::text_box::operator=(poppler::text_box)’
       text_box& operator=(text_box&&) = default;
                 ^
  /Users/vishalpatel/anaconda3/include/poppler/cpp/poppler-page.h:38:15: error: does not match expected signature ‘poppler::text_box& poppler::text_box::operator=(poppler::text_box&)’
  error: command 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for pdftotext
  Running setup.py clean for pdftotext
Failed to build pdftotext
Installing collected packages: pdftotext
  Running setup.py install for pdftotext ... error
    ERROR: Complete output from command /Users/vishalpatel/anaconda3/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/f1/wd32_gd10q58w4bdk8t5f1540000gn/T/pip-install-akx2k4vg/pdftotext/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/f1/wd32_gd10q58w4bdk8t5f1540000gn/T/pip-record-mt3cslmy/install-record.txt --single-version-externally-managed --compile:
    ERROR: running install
    running build
    running build_ext
    building 'pdftotext' extension
    creating build
    creating build/temp.macosx-10.7-x86_64-3.6
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/vishalpatel/anaconda3/include -arch x86_64 -I/Users/vishalpatel/anaconda3/include -arch x86_64 -DPOPPLER_CPP_AT_LEAST_0_30_0=1 -I/Users/vishalpatel/anaconda3/include/python3.6m -c pdftotext.cpp -o build/temp.macosx-10.7-x86_64-3.6/pdftotext.o -Wall -mmacosx-version-min=10.9
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
    In file included from pdftotext.cpp:5:0:
    /Users/vishalpatel/anaconda3/include/poppler/cpp/poppler-page.h:37:22: error: expected ‘,’ or ‘...’ before ‘&&’ token
         text_box(text_box&&) = default;
                          ^
    /Users/vishalpatel/anaconda3/include/poppler/cpp/poppler-page.h:37:28: error: invalid constructor; you probably meant ‘poppler::text_box (const poppler::text_box&)’
         text_box(text_box&&) = default;
                                ^
    /Users/vishalpatel/anaconda3/include/poppler/cpp/poppler-page.h:38:33: error: expected ‘,’ or ‘...’ before ‘&&’ token
         text_box& operator=(text_box&&) = default;
                                     ^
    /Users/vishalpatel/anaconda3/include/poppler/cpp/poppler-page.h:63:5: error: ‘unique_ptr’ in namespace ‘std’ does not name a type
         std::unique_ptr<text_box_data> m_data;
         ^
    /Users/vishalpatel/anaconda3/include/poppler/cpp/poppler-page.h:38:15: error: defaulted declaration ‘poppler::text_box& poppler::text_box::operator=(poppler::text_box)’
         text_box& operator=(text_box&&) = default;
                   ^
    /Users/vishalpatel/anaconda3/include/poppler/cpp/poppler-page.h:38:15: error: does not match expected signature ‘poppler::text_box& poppler::text_box::operator=(poppler::text_box&)’
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command "/Users/vishalpatel/anaconda3/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/f1/wd32_gd10q58w4bdk8t5f1540000gn/T/pip-install-akx2k4vg/pdftotext/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/f1/wd32_gd10q58w4bdk8t5f1540000gn/T/pip-record-mt3cslmy/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/f1/wd32_gd10q58w4bdk8t5f1540000gn/T/pip-install-akx2k4vg/pdftotext/
Vishals-MacBook-Air:~ vishalpatel$ 

我不确定通过自制软件或pip安装pdftottext的最有效方法对我来说是否合适,但目前这两种方法均无效。我对此很陌生,因此如果未能以正确的方式提出此问题或未提供正确的信息,我们深表歉意。

0 个答案:

没有答案