pdftotext: error: command 'gcc' failed with exit status 1

Hi,

I’m having trouble installing pdftotext. I’m using Python 3.6 on Anaconda 5.2.0 and pip version 18.0. There seems to be a problem with gcc so I did conda install libgcc but that didn’t make any difference. I also made sure python3-dev was installed.

john@john-Virtual-Machine:~/py3eg$` pip install pdftotext
Collecting pdftotext
  Using cached https://files.pythonhosted.org/packages/96/41/aa31f4a6809eb0574674d6c0cf6bc0e00aaf0ea53c62db8a2d9af50b7cc6/pdftotext-2.1.0.tar.gz
Building wheels for collected packages: pdftotext
  Running setup.py bdist_wheel for pdftotext ... error
  Complete output from command /home/john/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-9uyu6ggf/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 /tmp/pip-wheel-epbnqs4m --python-tag cp36:
  running bdist_wheel
  running build
  running build_ext
  building 'pdftotext' extension
  creating build
  creating build/temp.linux-x86_64-3.6
  gcc -pthread -B /home/john/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPOPPLER_CPP_AT_LEAST_0_30_0=0 -I/home/john/anaconda3/include/python3.6m -c pdftotext.cpp -o build/temp.linux-x86_64-3.6/pdftotext.o -Wall
  cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
  pdftotext.cpp:3:10: fatal error: poppler/cpp/poppler-document.h: No such file or directory
   #include <poppler/cpp/poppler-document.h>
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  compilation terminated.
  error: command 'gcc' failed with exit status 1
  
  ----------------------------------------
  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
    Complete output from command /home/john/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-9uyu6ggf/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 /tmp/pip-record-sx0bea7r/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_ext
    building 'pdftotext' extension
    creating build
    creating build/temp.linux-x86_64-3.6
    gcc -pthread -B /home/john/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPOPPLER_CPP_AT_LEAST_0_30_0=0 -I/home/john/anaconda3/include/python3.6m -c pdftotext.cpp -o build/temp.linux-x86_64-3.6/pdftotext.o -Wall
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
    pdftotext.cpp:3:10: fatal error: poppler/cpp/poppler-document.h: No such file or directory
     #include <poppler/cpp/poppler-document.h>
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    
    ----------------------------------------
Command "/home/john/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-9uyu6ggf/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 /tmp/pip-record-sx0bea7r/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-9uyu6ggf/pdftotext/

Any help would be greatly appreciated.

Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 24 (9 by maintainers)

Most upvoted comments

Since this project uses poppler’s CPP interface, you also need the libpoppler-cpp-dev package

I’m using this in a Dockerized environment and simply doing apt-get install libpoppler-cpp-dev did it for me thanks @jalan !

@lhyGit libpoppler-cpp-dev is one of the packages needed on Debian-based systems. For macOS, the packages you need are installed via brew install pkg-config poppler

If you still have issues after installing those, can you provide the output of pip --verbose install pdftotext here?

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 /usr/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-O5algo/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 /tmp/pip-wheel-oMHm6f --python-tag cp27:
  ERROR: running bdist_wheel
  running build
  running build_ext
  building 'pdftotext' extension
  creating build
  creating build/temp.linux-x86_64-2.7
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DPOPPLER_CPP_AT_LEAST_0_30_0=1 -I/usr/include/python2.7 -c pdftotext.cpp -o build/temp.linux-x86_64-2.7/pdftotext.o -Wall
  cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
  In file included from pdftotext.cpp:5:0:
  /usr/local/include/poppler/cpp/poppler-page.h:39:22: error: expected ‘,’ or ‘...’ before ‘&&’ token
       text_box(text_box&&);
                        ^
  /usr/local/include/poppler/cpp/poppler-page.h:39:24: error: invalid constructor; you probably meant ‘poppler::text_box (const poppler::text_box&)’
       text_box(text_box&&);
                          ^
  /usr/local/include/poppler/cpp/poppler-page.h:40:33: error: expected ‘,’ or ‘...’ before ‘&&’ token
       text_box& operator=(text_box&&);
                                   ^
  /usr/local/include/poppler/cpp/poppler-page.h:70:10: error: ‘unique_ptr’ in namespace ‘std’ does not name a template type
       std::unique_ptr<text_box_data> m_data;
            ^
  error: command 'x86_64-linux-gnu-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 /usr/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-O5algo/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 /tmp/pip-record-TF1_ts/install-record.txt --single-version-externally-managed --compile:
    ERROR: running install
    running build
    running build_ext
    building 'pdftotext' extension
    creating build
    creating build/temp.linux-x86_64-2.7
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DPOPPLER_CPP_AT_LEAST_0_30_0=1 -I/usr/include/python2.7 -c pdftotext.cpp -o build/temp.linux-x86_64-2.7/pdftotext.o -Wall
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
    In file included from pdftotext.cpp:5:0:
    /usr/local/include/poppler/cpp/poppler-page.h:39:22: error: expected ‘,’ or ‘...’ before ‘&&’ token
         text_box(text_box&&);
                          ^
    /usr/local/include/poppler/cpp/poppler-page.h:39:24: error: invalid constructor; you probably meant ‘poppler::text_box (const poppler::text_box&)’
         text_box(text_box&&);
                            ^
    /usr/local/include/poppler/cpp/poppler-page.h:40:33: error: expected ‘,’ or ‘...’ before ‘&&’ token
         text_box& operator=(text_box&&);
                                     ^
    /usr/local/include/poppler/cpp/poppler-page.h:70:10: error: ‘unique_ptr’ in namespace ‘std’ does not name a template type
         std::unique_ptr<text_box_data> m_data;
              ^
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command "/usr/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-O5algo/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 /tmp/pip-record-TF1_ts/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-O5algo/pdftotext/

@GD-A-150800 Please don’t post new unrelated questions on a closed issue.

I’m sorry to say that there is no support for Windows. The relevant issue in this case is #16.