title: Improperly configured: Usage of the xml aspects requires lxml and defusedxml
body: <p>I'm trying to use XML for a Django website I'm making but I ran into the following error when I set the page to display xml: </p>
  
  <pre><code>ImproperlyConfigured at /articles/api/article/
  
  Usage of the XML aspects requires lxml and defusedxml.
  </code></pre>
  
  <p>The page was working the way I wanted it to when I set it to display json. And I thought I installed lxml and defusedxml when I used the command </p>
  
  <pre><code>pip install defusedxml "lxml&gt;=3"
  </code></pre>
  
  <p>But I got this log on the command line. It was installing fine until some errors popped up: </p>
  
  <pre><code>Collecting defusedxml
    Using cached defusedxml-0.4.1.tar.gz
  Collecting lxml&gt;=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 -&gt; build/lib.linux-x86_64-2.7/lxml
  
      copying src/lxml/usedoctest.py -&gt; build/lib.linux-x86_64-2.7/lxml
  
      copying src/lxml/cssselect.py -&gt; build/lib.linux-x86_64-2.7/lxml
  
      copying src/lxml/sax.py -&gt; build/lib.linux-x86_64-2.7/lxml
  
      copying src/lxml/pyclasslookup.py -&gt; build/lib.linux-x86_64-2.7/lxml
  
      copying src/lxml/__init__.py -&gt; build/lib.linux-x86_64-2.7/lxml
  
      copying src/lxml/ElementInclude.py -&gt; build/lib.linux-x86_64-2.7/lxml
  
      copying src/lxml/doctestcompare.py -&gt; build/lib.linux-x86_64-2.7/lxml
  
      copying src/lxml/builder.py -&gt; build/lib.linux-x86_64-2.7/lxml
  
      creating build/lib.linux-x86_64-2.7/lxml/includes
  
      copying src/lxml/includes/__init__.py -&gt; 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 -&gt; build/lib.linux-x86_64-2.7/lxml/html
  
      copying src/lxml/html/defs.py -&gt; build/lib.linux-x86_64-2.7/lxml/html
  
      copying src/lxml/html/usedoctest.py -&gt; build/lib.linux-x86_64-2.7/lxml/html
  
      copying src/lxml/html/clean.py -&gt; build/lib.linux-x86_64-2.7/lxml/html
  
      copying src/lxml/html/ElementSoup.py -&gt; build/lib.linux-x86_64-2.7/lxml/html
  
      copying src/lxml/html/formfill.py -&gt; build/lib.linux-x86_64-2.7/lxml/html
  
      copying src/lxml/html/__init__.py -&gt; build/lib.linux-x86_64-2.7/lxml/html
  
      copying src/lxml/html/soupparser.py -&gt; build/lib.linux-x86_64-2.7/lxml/html
  
      copying src/lxml/html/diff.py -&gt; build/lib.linux-x86_64-2.7/lxml/html
  
      copying src/lxml/html/_html5builder.py -&gt; build/lib.linux-x86_64-2.7/lxml/html
  
      copying src/lxml/html/_setmixin.py -&gt; build/lib.linux-x86_64-2.7/lxml/html
  
      copying src/lxml/html/_diffcommand.py -&gt; build/lib.linux-x86_64-2.7/lxml/html
  
      copying src/lxml/html/builder.py -&gt; 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 -&gt; build/lib.linux-x86_64-2.7/lxml/isoschematron
  
      copying src/lxml/lxml.etree.h -&gt; build/lib.linux-x86_64-2.7/lxml
  
      copying src/lxml/lxml.etree_api.h -&gt; build/lib.linux-x86_64-2.7/lxml
  
      copying src/lxml/includes/uri.pxd -&gt; build/lib.linux-x86_64-2.7/lxml/includes
  
      copying src/lxml/includes/etreepublic.pxd -&gt; build/lib.linux-x86_64-2.7/lxml/includes
  
     copying src/lxml/includes/xinclude.pxd -&gt; build/lib.linux-x86_64-2.7/lxml/includes
  
     copying src/lxml/includes/xmlerror.pxd -&gt; build/lib.linux-x86_64-2.7/lxml/includes
  
     copying src/lxml/includes/htmlparser.pxd -&gt; build/lib.linux-x86_64-2.7/lxml/includes
  
  copying src/lxml/includes/xmlschema.pxd -&gt; build/lib.linux-x86_64-2.7/lxml/includes
  
   copying src/lxml/includes/schematron.pxd -&gt; build/lib.linux-x86_64-2.7/lxml/includes
  
  copying src/lxml/includes/tree.pxd -&gt; build/lib.linux-x86_64-2.7/lxml/includes
  
  copying src/lxml/includes/dtdvalid.pxd -&gt; build/lib.linux-x86_64-2.7/lxml/includes
  
  copying src/lxml/includes/xslt.pxd -&gt; build/lib.linux-x86_64-2.7/lxml/includes
  
  copying src/lxml/includes/c14n.pxd -&gt; build/lib.linux-x86_64-2.7/lxml/includes
  
  copying src/lxml/includes/config.pxd -&gt; build/lib.linux-x86_64-2.7/lxml/includes
  
  copying src/lxml/includes/xpath.pxd -&gt; build/lib.linux-x86_64-2.7/lxml/includes
  
  copying src/lxml/includes/relaxng.pxd -&gt; build/lib.linux-x86_64-2.7/lxml/includes
  
  copying src/lxml/includes/xmlparser.pxd -&gt; build/lib.linux-x86_64-2.7/lxml/includes
  
  copying src/lxml/includes/etree_defs.h -&gt; build/lib.linux-x86_64-2.7/lxml/includes
  
  copying src/lxml/includes/lxml-version.h -&gt; 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 -&gt; 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 -&gt; build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl
  
  copying src/lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl -&gt; 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 -&gt; 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 -&gt; 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 -&gt; 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 -&gt; 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 -&gt; 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 -&gt; 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
  </code></pre>
  
  <p>I looked at similar posts about errors when installing lxml but these posts didn't have the same error messages as mine. I looked at the lxml documentation and tried to install it according to the documentation, but I still cannot get lxml or defusedxml installed. </p>
  
  <p>I don't know what I'm installing incorrectly or what to do. But I appreciate any help that you can give me. Thank you.</p>