2015-02-10 42 views
0

我試圖使用XML的Django的網站我在做,但我遇到了以下錯誤,當我設置頁面中顯示XML:配置不當:的XML方面的使用需要LXML和defusedxml

ImproperlyConfigured at /articles/api/article/ 

Usage of the XML aspects requires lxml and defusedxml. 

當我將它設置爲顯示json時,該頁面以我想要的方式工作。我以爲我使用命令時安裝了lxml和defusedxml

pip install defusedxml "lxml>=3" 

但是我在命令行上得到了這個日誌。它安裝罰款,直至一些錯誤彈出:

Collecting defusedxml 
    Using cached defusedxml-0.4.1.tar.gz 
Collecting lxml>=3 
    Using cached lxml-3.4.2.tar.gz 
    /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url' 
     warnings.warn(msg) 
     Building lxml version 3.4.2. 
     Building without Cython. 
     Using build configuration of libxslt 1.1.28 
Installing collected packages: lxml, defusedxml 
    Running setup.py install for lxml 
    /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url' 
     warnings.warn(msg) 
    Building lxml version 3.4.2. 
    Building without Cython. 
    Using build configuration of libxslt 1.1.28 
    building 'lxml.etree' extension 
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/libxml2 -I/tmp/pip-build-HDr23E/lxml/src/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o -w 
    x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.linux-x86_64-2.7/lxml/etree.so 
    /usr/bin/ld: cannot find -lz 
    collect2: error: ld returned 1 exit status 
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 
    Complete output from command /home/deanna/django-deanna/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-HDr23E/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-TMZGKJ-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/deanna/django-deanna/include/site/python2.7: 
    /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url' 

     warnings.warn(msg) 

    Building lxml version 3.4.2. 

    Building without Cython. 

    Using build configuration of libxslt 1.1.28 

    running install 

    running build 

    running build_py 

    creating build 

    creating build/lib.linux-x86_64-2.7 

    creating build/lib.linux-x86_64-2.7/lxml 

    copying src/lxml/_elementpath.py -> build/lib.linux-x86_64-2.7/lxml 

    copying src/lxml/usedoctest.py -> build/lib.linux-x86_64-2.7/lxml 

    copying src/lxml/cssselect.py -> build/lib.linux-x86_64-2.7/lxml 

    copying src/lxml/sax.py -> build/lib.linux-x86_64-2.7/lxml 

    copying src/lxml/pyclasslookup.py -> build/lib.linux-x86_64-2.7/lxml 

    copying src/lxml/__init__.py -> build/lib.linux-x86_64-2.7/lxml 

    copying src/lxml/ElementInclude.py -> build/lib.linux-x86_64-2.7/lxml 

    copying src/lxml/doctestcompare.py -> build/lib.linux-x86_64-2.7/lxml 

    copying src/lxml/builder.py -> build/lib.linux-x86_64-2.7/lxml 

    creating build/lib.linux-x86_64-2.7/lxml/includes 

    copying src/lxml/includes/__init__.py -> build/lib.linux-x86_64-2.7/lxml/includes 

    creating build/lib.linux-x86_64-2.7/lxml/html 

    copying src/lxml/html/html5parser.py -> build/lib.linux-x86_64-2.7/lxml/html 

    copying src/lxml/html/defs.py -> build/lib.linux-x86_64-2.7/lxml/html 

    copying src/lxml/html/usedoctest.py -> build/lib.linux-x86_64-2.7/lxml/html 

    copying src/lxml/html/clean.py -> build/lib.linux-x86_64-2.7/lxml/html 

    copying src/lxml/html/ElementSoup.py -> build/lib.linux-x86_64-2.7/lxml/html 

    copying src/lxml/html/formfill.py -> build/lib.linux-x86_64-2.7/lxml/html 

    copying src/lxml/html/__init__.py -> build/lib.linux-x86_64-2.7/lxml/html 

    copying src/lxml/html/soupparser.py -> build/lib.linux-x86_64-2.7/lxml/html 

    copying src/lxml/html/diff.py -> build/lib.linux-x86_64-2.7/lxml/html 

    copying src/lxml/html/_html5builder.py -> build/lib.linux-x86_64-2.7/lxml/html 

    copying src/lxml/html/_setmixin.py -> build/lib.linux-x86_64-2.7/lxml/html 

    copying src/lxml/html/_diffcommand.py -> build/lib.linux-x86_64-2.7/lxml/html 

    copying src/lxml/html/builder.py -> build/lib.linux-x86_64-2.7/lxml/html 

    creating build/lib.linux-x86_64-2.7/lxml/isoschematron 

    copying src/lxml/isoschematron/__init__.py -> build/lib.linux-x86_64-2.7/lxml/isoschematron 

    copying src/lxml/lxml.etree.h -> build/lib.linux-x86_64-2.7/lxml 

    copying src/lxml/lxml.etree_api.h -> build/lib.linux-x86_64-2.7/lxml 

    copying src/lxml/includes/uri.pxd -> build/lib.linux-x86_64-2.7/lxml/includes 

    copying src/lxml/includes/etreepublic.pxd -> build/lib.linux-x86_64-2.7/lxml/includes 

    copying src/lxml/includes/xinclude.pxd -> build/lib.linux-x86_64-2.7/lxml/includes 

    copying src/lxml/includes/xmlerror.pxd -> build/lib.linux-x86_64-2.7/lxml/includes 

    copying src/lxml/includes/htmlparser.pxd -> build/lib.linux-x86_64-2.7/lxml/includes 

copying src/lxml/includes/xmlschema.pxd -> build/lib.linux-x86_64-2.7/lxml/includes 

copying src/lxml/includes/schematron.pxd -> build/lib.linux-x86_64-2.7/lxml/includes 

copying src/lxml/includes/tree.pxd -> build/lib.linux-x86_64-2.7/lxml/includes 

copying src/lxml/includes/dtdvalid.pxd -> build/lib.linux-x86_64-2.7/lxml/includes 

copying src/lxml/includes/xslt.pxd -> build/lib.linux-x86_64-2.7/lxml/includes 

copying src/lxml/includes/c14n.pxd -> build/lib.linux-x86_64-2.7/lxml/includes 

copying src/lxml/includes/config.pxd -> build/lib.linux-x86_64-2.7/lxml/includes 

copying src/lxml/includes/xpath.pxd -> build/lib.linux-x86_64-2.7/lxml/includes 

copying src/lxml/includes/relaxng.pxd -> build/lib.linux-x86_64-2.7/lxml/includes 

copying src/lxml/includes/xmlparser.pxd -> build/lib.linux-x86_64-2.7/lxml/includes 

copying src/lxml/includes/etree_defs.h -> build/lib.linux-x86_64-2.7/lxml/includes 

copying src/lxml/includes/lxml-version.h -> build/lib.linux-x86_64-2.7/lxml/includes 

creating build/lib.linux-x86_64-2.7/lxml/isoschematron/resources 

creating build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/rng 

copying src/lxml/isoschematron/resources/rng/iso-schematron.rng -> build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/rng 

creating build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl 

copying src/lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl -> build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl 

copying src/lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl -> build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl 

creating build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1 

copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl -> build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1 

copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl -> build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1 

copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl -> build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1 

copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl -> build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1 

copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl -> build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1 

copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt -> build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1 

running build_ext 

building 'lxml.etree' extension 

creating build/temp.linux-x86_64-2.7 

creating build/temp.linux-x86_64-2.7/src 

creating build/temp.linux-x86_64-2.7/src/lxml 

x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/libxml2 -I/tmp/pip-build-HDr23E/lxml/src/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o -w 

x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.linux-x86_64-2.7/lxml/etree.so 

/usr/bin/ld: cannot find -lz 

collect2: error: ld returned 1 exit status 

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 

---------------------------------------- 
Command "/home/deanna/django-deanna/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-HDr23E/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-TMZGKJ-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/deanna/django-deanna/include/site/python2.7" failed with error code 1 in /tmp/pip-build-HDr23E/lxml 

我看了有關錯誤類似的帖子在安裝時LXML但這些崗位沒有相同的錯誤消息的礦。我查看了lxml文檔,並根據文檔嘗試安裝它,但我仍然無法安裝lxml或defusedxml。

我不知道我安裝不正確或要做什麼。但是,我感謝您能給我的任何幫助。謝謝。

回答

0

錯誤「/ usr/bin/ld:找不到-lz」:這意味着您沒有安裝zlib-dev或zlib1g-dev,具體取決於您的linux發行版,請嘗試先安裝此庫。

+0

我解決了這個問題,但我使用了apt-get install lib32z1-dev命令。謝謝你。 – brown1001 2015-02-10 20:06:59