Reputation: 14724
On my project, I have issues with my test scripts on Travis CI. I installed the packages that I needed using conda, and then ran my test scripts. The build fails because of import errors. How can I fix this?
My travis YAML file is as such:
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
One of my test scripts requires BioPython, and the test script fails because it cannot find 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'
Is there a way to fix this?
Upvotes: 2
Views: 626
Reputation: 14724
Turns out the problem was py.test
- I didn't install it in the conda
environment. Adding pytest
to the packages to install when creating the new environment made those import errors go away.
Upvotes: 1