Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: PyCapsule_Import could not import module "pyexpat"

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.

One of them is failing with the following error.

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 <module>
    from main import app
  File "/opt/bitnami/apps/jenkins/jenkins_home/jobs/CFC Melbourne production pipeline/workspace/main.py", line 28, in <module>
    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 <module>
    from thirdpartylib import cloudstorage
  File "/opt/bitnami/apps/jenkins/jenkins_home/jobs/CFC Melbourne production pipeline/workspace/thirdpartylib/cloudstorage/__init__.py", line 22, in <module>
    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 <module>
    import xml.etree.cElementTree as ET
  File "/usr/lib/python2.7/xml/etree/cElementTree.py", line 3, in <module>
    from _elementtree import *
ImportError: PyCapsule_Import could not import module "pyexpat"

I have logged onto the VM and searched for this module and this is what i get

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

I guess its install but the module cannot be imported. Please help.

The module is in the python path.

>>> import sys
>>> 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']
>>> 
like image 874
Vinay Joseph Avatar asked Jun 28 '15 13:06

Vinay Joseph


1 Answers

I found a workaround to this issue:

In your jenkins script, just clear LD_LIBRARY_PATH variable at the beginning:

export LD_LIBRARY_PATH=""

This does the trick!!

like image 170
Luis Avatar answered Oct 22 '22 19:10

Luis