title: ImportError: PyCapsule_Import could not import module "pyexpat"
body: <p>I am using Jenkins to build a python (Flask) solution to deploy to Google App Engine. As part of the build process I run a few integration tests. </p>
  
  <p>One of them is failing with the following error. </p>
  
  <pre><code>ERROR: Failure: ImportError (PyCapsule_Import could not import module "pyexpat")
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "/usr/local/lib/python2.7/dist-packages/nose-1.3.6-py2.7.egg/nose/loader.py", line 420, in loadTestsFromName
      addr.filename, addr.module)
    File "/usr/local/lib/python2.7/dist-packages/nose-1.3.6-py2.7.egg/nose/importer.py", line 47, in importFromPath
      return self.importFromDir(dir_path, fqname)
    File "/usr/local/lib/python2.7/dist-packages/nose-1.3.6-py2.7.egg/nose/importer.py", line 94, in importFromDir
      mod = load_module(part_fqname, fh, filename, desc)
    File "/opt/bitnami/apps/jenkins/jenkins_home/jobs/CFC Melbourne production pipeline/workspace/Tests/test_integration.py", line 4, in &lt;module&gt;
      from main import app
    File "/opt/bitnami/apps/jenkins/jenkins_home/jobs/CFC Melbourne production pipeline/workspace/main.py", line 28, in &lt;module&gt;
      from Routes.AdminRoutes import admin_routes
    File "/opt/bitnami/apps/jenkins/jenkins_home/jobs/CFC Melbourne production pipeline/workspace/Routes/AdminRoutes.py", line 7, in &lt;module&gt;
      from thirdpartylib import cloudstorage
    File "/opt/bitnami/apps/jenkins/jenkins_home/jobs/CFC Melbourne production pipeline/workspace/thirdpartylib/cloudstorage/__init__.py", line 22, in &lt;module&gt;
      from cloudstorage_api import *
    File "/opt/bitnami/apps/jenkins/jenkins_home/jobs/CFC Melbourne production pipeline/workspace/thirdpartylib/cloudstorage/cloudstorage_api.py", line 37, in &lt;module&gt;
      import xml.etree.cElementTree as ET
    File "/usr/lib/python2.7/xml/etree/cElementTree.py", line 3, in &lt;module&gt;
      from _elementtree import *
  ImportError: PyCapsule_Import could not import module "pyexpat"
  </code></pre>
  
  <p>I have logged onto the VM and searched for this module and this is what i get</p>
  
  <pre><code>xxx@jenkins-pre1:~$ sudo find / -name pyexpat*
  /usr/lib/python2.7/lib-dynload/pyexpat.so
  /var/lib/docker/aufs/diff/d0cfa9780fa540e496fd60e38f32c58708374a4a62bc8a6462834c7757a31cdf/usr/lib/python2.7/lib-dy
  nload/pyexpat.x86_64-linux-gnu.so
  </code></pre>
  
  <p>I guess its install but the module cannot be imported. Please help. </p>
  
  <p>The module is in the python path. </p>
  
  <pre><code>&gt;&gt;&gt; import sys
  &gt;&gt;&gt; print sys.path
  ['', '/usr/local/lib/python2.7/dist-packages/setuptools-15.2-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/no
  se-1.3.6-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/pip-7.0.3-py2.7.egg', '/usr/lib/python2.7', '/usr/lib/
  python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload'
  , '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/pymodules/python2.7']
  &gt;&gt;&gt; 
  </code></pre>