python - 导入错误: No module named libxml2 within Travis build

标签 python libxml2 travis-ci

我知道这个问题之前已经被问过,但我的问题是在 travis build 中。我已经安装了文档中列出的所有依赖项,

检查我的 travis 配置。

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

但我无法让它运行:

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

我已经没有任何线索了。 我的存储库:https://github.com/danimaribeiro/PyTrustNFe

为了供将来引用,此问题的一种解决方案如下: http://danielnouri.org/notes/2012/11/23/use-apt-get-to-install-python-dependencies-for-travis-ci/

最佳答案

线索就在错误消息中;您正在针对系统 Python 运行某些组件,而其他组件则针对虚拟环境运行;我没有在你的脚本中看到它的设置。

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

关于python - 导入错误: No module named libxml2 within Travis build,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30837431/

相关文章:

python - 使用 loc 方法获取 DataFrame 的 View

python - pandas read csv 在固定时间内使用定界符

c++ - 如何解析 "relocation truncated to fit: R_X86_64_PC32 against undefined symbol ` xmlStrcmp'”

php - 使用具有代码覆盖率和 Travis CI 的 PHPUnit 时测试失败

travis-ci - Travis 找不到我的 travis.yml 文件

python - Python 中 elif 语句的语法错误...?

python - 在文件中要求输入使用带有文件内容的字符串

c++ - 回滚 XML 功能

c - MSYS : Error c compiler cannot create executables

caching - 如何缓存Travis CI中已通过 `apt-get`安装的软件包?