ImportError: No module named libxml2 within Travis build

2k views Asked by At

I know this question has been asked before, but my problem is within travis build. I have installed all the dependencies listed in the documentation,

Check my travis configuration.

language: python
python:
  - "2.7"
install:
  - pip install -r requirements.txt
  - pip install PyXmlSec --allow-external PyXMLSec --allow-insecure PyXMLSec
  - pip install coveralls
script: 
  coverage run --source=pytrustnfe setup.py nosetests
before_install:
  - sudo apt-get update -qq
  - sudo apt-get install -qq libxml2-dev libxmlsec1-dev libxslt-dev 
  - sudo apt-get install -qq python-dev python-lxml python-libxml2
  - sudo apt-get install -qq python-libxslt1 libxml2
  - sudo apt-get install -qq build-essential
after_success:
  coveralls

But I can't get it to run:

File "/home/travis/build/danimaribeiro/PyTrustNFe/pytrustnfe/servicos/assinatura.py", line 6, in <module>
    import xmlsec, libxml2
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/xmlsec.py", line 33, in <module>
    import libxml2
ImportError: No module named libxml2

I have no clues anymore. My repository: https://github.com/danimaribeiro/PyTrustNFe

For future references, one solution to this problem is here: http://danielnouri.org/notes/2012/11/23/use-apt-get-to-install-python-dependencies-for-travis-ci/

1

There are 1 answers

2
Burhan Khalid On BEST ANSWER

The clue is in the error message; you are running some components against the system Python, and others against a virtual environment; which I didn't see being setup in your script.

File "/home/travis/build/danimaribeiro/PyTrustNFe/pytrustnfe/servicos/assinatura.py", line 6, in import xmlsec, libxml2 File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/xmlsec.py", line 33, in import libxml2 ImportError: No module named libxml2