Travis CI python导入不起作用

时间:2015-07-14 16:10:02

标签: python travis-ci

在我的项目中,我在Travis CI上遇到了测试脚本问题。我使用conda安装了我需要的软件包,然后运行了我的测试脚本。由于导入错误,构建失败。我怎样才能解决这个问题?

我的travis YAML文件是这样的:

language: python
python:
  - "2.7"
  - "3.4"
  - "nightly"

# command to install dependencies
# setup anaconda
before_install:
  - wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh
  - chmod +x miniconda.sh
  - bash miniconda.sh -b -p $HOME/miniconda
  - export PATH="$HOME/miniconda/bin:$PATH"
  - conda update -y conda

# install packages
install:
  - conda install -y numpy scipy matplotlib networkx biopython
  - echo $PATH
  - which python


# command to run tests
script: py.test

我的一个测试脚本需要BioPython,测试脚本失败,因为它无法找到biopython。

__________________ ERROR collecting test_genotype_network.py ___________________
test_genotype_network.py:1: in <module>
    import genotype_network as gn
genotype_network.py:1: in <module>
    from Bio import SeqIO
E   ImportError: No module named 'Bio'

有没有办法解决这个问题?

1 个答案:

答案 0 :(得分:1)

原来问题是py.test - 我没有在conda环境中安装它。在创建新环境时将pytest添加到要安装的软件包中会导致导入错误消失。

相关问题