我正在尝试在(dockerized)Debian上安装python软件包textract

FROM python:2.7
RUN apt-get update
RUN apt-get -y upgrade
RUN apt-get -y install libevent-dev python-dev libxml2-dev libxslt1-dev antiword unrtf poppler-utils pstotext tesseract-ocr flac ffmpeg lame libmad0 libsox-fmt-mp3 sox libjpeg-dev swig
RUN pip install textract


但是在最后一步pip install textract上失败。为什么?如何解决这个问题?下面是错误:

Building wheels for collected packages: textract, python-pptx, docx2txt, xlrd, EbookLib, pocketsphinx
  Running setup.py bdist_wheel for textract: started
  Running setup.py bdist_wheel for textract: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/7b/88/ca/fe02cca616f52ba41e11ee9eff08ca0d8391f3df35e0ede5e2
  Running setup.py bdist_wheel for python-pptx: started
  Running setup.py bdist_wheel for python-pptx: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/14/50/ec/bf4ff7cedffcde6ef29d3154f758a5d65f40427f526cbdb1d5
  Running setup.py bdist_wheel for docx2txt: started
  Running setup.py bdist_wheel for docx2txt: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/a8/a1/2e/61cea06f166c6f6ac4df4d75a409328406bd0d2f8e007592f9
  Running setup.py bdist_wheel for xlrd: started
  Running setup.py bdist_wheel for xlrd: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/f7/2e/62/b4b26f9bc16968996a93dab7a1ec3cf9a1c8ca409114f4fefe
  Running setup.py bdist_wheel for EbookLib: started
  Running setup.py bdist_wheel for EbookLib: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/3a/b9/cb/834288199b3b3c6c08441d5780ce4a6cfc161d4c859f28a915
  Running setup.py bdist_wheel for pocketsphinx: started
  Running setup.py bdist_wheel for pocketsphinx: finished with status 'error'
  Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-rkBOkm/pocketsphinx/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-lmkSIP --python-tag cp27:
  running bdist_wheel
  running build_ext
  building 'sphinxbase._ad' extension
  swigging swig/sphinxbase/ad.i to swig/sphinxbase/ad_wrap.c
  swig -python -modern -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/android -Ideps/sphinxbase/swig -outdir sphinxbase -o swig/sphinxbase/ad_wrap.c swig/sphinxbase/ad.i
  creating build
  creating build/temp.linux-x86_64-2.7
  creating build/temp.linux-x86_64-2.7/swig
  creating build/temp.linux-x86_64-2.7/swig/sphinxbase
  creating build/temp.linux-x86_64-2.7/deps
  creating build/temp.linux-x86_64-2.7/deps/sphinxbase
  creating build/temp.linux-x86_64-2.7/deps/sphinxbase/src
  creating build/temp.linux-x86_64-2.7/deps/sphinxbase/src/libsphinxad
  gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DSPHINXBASE_EXPORTS -DPOCKETSPHINX_EXPORTS -DSPHINX_DLL -DHAVE_CONFIG_H -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/android -I/usr/local/include/python2.7 -c swig/sphinxbase/ad_wrap.c -o build/temp.linux-x86_64-2.7/swig/sphinxbase/ad_wrap.o -Wno-unused-label -Wno-strict-prototypes -Wno-parentheses -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-result -Wno-sign-compare -Wno-misleading-indentation
  gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DSPHINXBASE_EXPORTS -DPOCKETSPHINX_EXPORTS -DSPHINX_DLL -DHAVE_CONFIG_H -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/android -I/usr/local/include/python2.7 -c deps/sphinxbase/src/libsphinxad/ad_pulse.c -o build/temp.linux-x86_64-2.7/deps/sphinxbase/src/libsphinxad/ad_pulse.o -Wno-unused-label -Wno-strict-prototypes -Wno-parentheses -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-result -Wno-sign-compare -Wno-misleading-indentation
  deps/sphinxbase/src/libsphinxad/ad_pulse.c:44:30: fatal error: pulse/pulseaudio.h: No such file or directory
   #include <pulse/pulseaudio.h>
                                ^
  compilation terminated.
  error: command 'gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for pocketsphinx
  Running setup.py clean for pocketsphinx
Successfully built textract python-pptx docx2txt xlrd EbookLib
Failed to build pocketsphinx
requests 2.20.0 has requirement chardet<3.1.0,>=3.0.2, but you'll have chardet 2.3.0 which is incompatible.
Installing collected packages: argcomplete, chardet, Pillow, XlsxWriter, python-pptx, docx2txt, beautifulsoup4, xlrd, six, EbookLib, SpeechRecognition, pocketsphinx, textract
  Found existing installation: chardet 3.0.4
    Uninstalling chardet-3.0.4:
      Successfully uninstalled chardet-3.0.4
  Found existing installation: beautifulsoup4 4.6.3
    Uninstalling beautifulsoup4-4.6.3:
      Successfully uninstalled beautifulsoup4-4.6.3
  Running setup.py install for pocketsphinx: started
    Running setup.py install for pocketsphinx: finished with status 'error'
    Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-rkBOkm/pocketsphinx/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-MiPh8Y/install-record.txt --single-version-externally-managed --compile:
    running install
    running build_ext
    building 'sphinxbase._ad' extension
    swigging swig/sphinxbase/ad.i to swig/sphinxbase/ad_wrap.c
    swig -python -modern -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/android -Ideps/sphinxbase/swig -outdir sphinxbase -o swig/sphinxbase/ad_wrap.c swig/sphinxbase/ad.i
    creating build
    creating build/temp.linux-x86_64-2.7
    creating build/temp.linux-x86_64-2.7/swig
    creating build/temp.linux-x86_64-2.7/swig/sphinxbase
    creating build/temp.linux-x86_64-2.7/deps
    creating build/temp.linux-x86_64-2.7/deps/sphinxbase
    creating build/temp.linux-x86_64-2.7/deps/sphinxbase/src
    creating build/temp.linux-x86_64-2.7/deps/sphinxbase/src/libsphinxad
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DSPHINXBASE_EXPORTS -DPOCKETSPHINX_EXPORTS -DSPHINX_DLL -DHAVE_CONFIG_H -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/android -I/usr/local/include/python2.7 -c swig/sphinxbase/ad_wrap.c -o build/temp.linux-x86_64-2.7/swig/sphinxbase/ad_wrap.o -Wno-unused-label -Wno-strict-prototypes -Wno-parentheses -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-result -Wno-sign-compare -Wno-misleading-indentation
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DSPHINXBASE_EXPORTS -DPOCKETSPHINX_EXPORTS -DSPHINX_DLL -DHAVE_CONFIG_H -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/android -I/usr/local/include/python2.7 -c deps/sphinxbase/src/libsphinxad/ad_pulse.c -o build/temp.linux-x86_64-2.7/deps/sphinxbase/src/libsphinxad/ad_pulse.o -Wno-unused-label -Wno-strict-prototypes -Wno-parentheses -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-result -Wno-sign-compare -Wno-misleading-indentation
    deps/sphinxbase/src/libsphinxad/ad_pulse.c:44:30: fatal error: pulse/pulseaudio.h: No such file or directory
     #include <pulse/pulseaudio.h>
                                  ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-rkBOkm/pocketsphinx/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-MiPh8Y/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-rkBOkm/pocketsphinx/
ERROR: Service 'baleen' failed to build: The command '/bin/sh -c pip install textract' returned a non-zero code: 1

最佳答案

解:
在安装textract之前先添加RUN apt-get -y install libpulse-dev

关于python - 为什么Debian上的pip安装textract失败?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54283100/

10-09 16:44