Проблемы с импортом pdftotext в python после установки с использованием homebrew cask - PullRequest
0 голосов
/ 10 июля 2019

Я пытаюсь разработать приложение, которое требует, чтобы я читал в тексте из PDF-файлов, поэтому я пытаюсь установить библиотеку Python pdftotext.Я использую Mac OS и Python через Anaconda.

Первоначально я пытался использовать pip install pdftotext, но постоянно сталкивался с ошибками типа «ошибка: команда« gcc »завершилась неудачно с состоянием выхода 1».Единственная зависимость, которую я вижу для Mac OS, - это pkg-config poppler, который я установил с помощью homebrew.Затем я нашел инструкции по установке pdftotext с помощью homebrew с помощью команды "brew cask install pdftotext".Он успешно устанавливается, однако, когда я пытаюсь импортировать его в свой блокнот, он сообщает, что нет модуля с именем pdftotext.

Ошибка при импорте из homebrew

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$ 

Я не уверен, какой самый эффективный способ установкиpdftottext, либо через homebrew, либо через pip, меня устраивает, но на данный момент ни один из методов не работает.Я очень новичок в этом, поэтому извиняюсь, если этот вопрос не был задан правильно или правильная информация не была предоставлена.

...