簡體   English   中英

在Cygwin上,virtualenv中的Python 2.7 pip install lxml失敗了

[英]Python 2.7 pip install lxml in virtualenv fails on Cygwin

在閱讀了我能找到的所有內容並嘗試了很多東西后,我無法確定原因/解決方案......

$ pip install lxml --no-compile --only-binary=:all | grep -v 'copying\|creating'
Collecting lxml
  Using cached lxml-3.7.2.tar.gz
Building wheels for collected packages: lxml
  Running setup.py bdist_wheel for lxml: started
  Running setup.py bdist_wheel for lxml: finished with status 'error'
  Complete output from command /cygdrive/c/Programs/Python27.v_env.Scrapy/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ADWe5d/lxml/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/tmphkkbinpip-wheel- --python-tag cp27:
  Building lxml version 3.7.2.
  Building without Cython.
  Using build configuration of libxslt 1.1.29
  Building against libxml2/libxslt in the following directory: /usr/lib
  running bdist_wheel
  running build
  running build_py
  Failed building wheel for lxml
  running build_ext
  building 'lxml.etree' extension
  gcc -fno-strict-aliasing -ggdb -O2 -pipe -Wimplicit-function-declaration -fdebug-prefix-map=/usr/src/ports/python/python-2.7.12-1.x86_64/build=/usr/src/debug/python-2.7.12-1 -fdebug-prefix-map=/usr/src/ports/python/python-2.7.12-1.x86_64/src/Python-2.7.12=/usr/src/debug/python-2.7.12-1 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/libxml2 -Isrc/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.cygwin-2.6.1-x86_64-2.7/src/lxml/lxml.etree.o -w
  src/lxml/lxml.etree.c:84:20: error: Python.h: No such file or directory
  src/lxml/lxml.etree.c:86:6: error: #error Python headers needed to compile C extensions, please install development version of Python.
  Compile failed: command 'gcc' failed with exit status 1
  cc -I/usr/include/libxml2 -I/usr/include/libxml2 -c /tmp/xmlXPathInittcKSfa.c -o tmp/xmlXPathInittcKSfa.o
  unable to execute 'cc': No such file or directory
  *********************************************************************************
  Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
  *********************************************************************************
  error: command 'gcc' failed with exit status 1

  ----------------------------------------
  Running setup.py clean for lxml
Failed to build lxml
Installing collected packages: lxml
  Running setup.py install for lxml: started
    Running setup.py install for lxml: finished with status 'error'
    Complete output from command /cygdrive/c/Programs/Python27.v_env.Scrapy/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ADWe5d/lxml/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-Hu4l_V-record/install-record.txt --single-version-externally-managed --no-compile --install-headers /cygdrive/c/Programs/Python27.v_env.Scrapy/include/site/python2.7/lxml:
    Building lxml version 3.7.2.
    Building without Cython.
    Using build configuration of libxslt 1.1.29
    Building against libxml2/libxslt in the following directory: /usr/lib
    running install
    running build
    running build_py
    running build_ext
    building 'lxml.etree' extension
    gcc -fno-strict-aliasing -ggdb -O2 -pipe -Wimplicit-function-declaration -fdebug-prefix-map=/usr/src/ports/python/python-2.7.12-1.x86_64/build=/usr/src/debug/python-2.7.12-1 -fdebug-prefix-map=/usr/src/ports/python/python-2.7.12-1.x86_64/src/Python-2.7.12=/usr/src/debug/python-2.7.12-1 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/libxml2 -Isrc/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.cygwin-2.6.1-x86_64-2.7/src/lxml/lxml.etree.o -w
    src/lxml/lxml.etree.c:84:20: error: Python.h: No such file or directory
    src/lxml/lxml.etree.c:86:6: error: #error Python headers needed to compile C extensions, please install development version of Python.
    Compile failed: command 'gcc' failed with exit status 1
    cc -I/usr/include/libxml2 -I/usr/include/libxml2 -c /tmp/xmlXPathInitSsqVxY.c -o tmp/xmlXPathInitSsqVxY.o
unable to execute 'cc': No such file or directory
  *********************************************************************************
  Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
  *********************************************************************************
  error: command 'gcc' failed with exit status 1

----------------------------------------
Command "/cygdrive/c/Programs/Python27.v_env.Scrapy/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ADWe5d/lxml/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-Hu4l_V-record/install-record.txt --single-version-externally-managed --no-compile --install-headers /cygdrive/c/Programs/Python27.v_env.Scrapy/include/site/python2.7/lxml" failed with error code 1 in /tmp/pip-build-ADWe5d/lxml/

報告為遺失的物品存在,據我所知...

$ find /usr/include -type f -name "Python.h"
/usr/include/python2.7/Python.h

$ apt-cyg show python-devel python-lxml libxml2-devel libxslt-devel | grep 'sdesc\|require\|version'
sdesc: "Python language interpreter"
requires: bash pkg-config python
version: 2.7.12-1
sdesc: "Python XML2/XSLT bindings"
requires: cygwin libxml2 libxslt python python-beautifulsoup
version: 3.4.4-1
sdesc: "GNOME XML library (development)"
requires: bash libxml2 pkg-config
version: 2.9.4-1
sdesc: "GNOME XSLT library (development)"
requires: bash cygwin-devel libgcrypt-devel libgpg-error-devel libiconv-devel liblzma-devel libxml2-devel libxslt pkg-config zlib-devel
version: 1.1.29-1

$ pip list | grep 'pip\|setup\|wheel'
pip (9.0.1)
setuptools (34.1.1)
wheel (0.29.0)

我試圖避免使用我在'pip install'上使用的選項進行編譯,但無濟於事。 任何見解將不勝感激。 謝謝。

我遇到了類似的問題。 我不得不安裝:

sudo apt-get install libxml2-dev libxslt-dev python-dev

根據http://lxml.de/installation.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM