【问题标题】:Travis build failing, no module named scipy (using Miniconda)Travis 构建失败,没有名为 scipy 的模块(使用 Miniconda)
【发布时间】:2016-05-24 11:28:06
【问题描述】:

我有一个依赖 scipy 的包。我已经知道通过apt-get 安装 scipy 会给我们一个过时版本的软件包,并且通过pip 安装它会使 Travis VM 超时,所以我决定在我的测试期间下载并安装 Miniconda,就像许多其他的建议一样问题。

但是,每当我推送到 GitHub 并且 Travis 运行我的单元测试时,它都无法找到 scipy 包。错误信息只是ImportError: No module named 'scipy'

这是我的.travis.yml 文件的内容。 python --version 正确指向“Python 3.4.4 :: Continuum Analytics, Inc.” conda list 显示已安装 scipy 0.17.0。如果有人有兴趣,这里是full log of my Travis build

language: python
python:
  # We don't actually use the Travis Python, but this keeps it organized.
  - "3.4"
install:
  - sudo apt-get update
  # We do this conditionally because it saves us some downloading if the
  # version is the same.
  - if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
      wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh;
    else
      wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
    fi
  - bash miniconda.sh -b -p $HOME/miniconda
  - export PATH="$HOME/miniconda/bin:$PATH"
  - hash -r
  - conda config --set always_yes yes --set changeps1 no
  - conda update -q conda
  # Useful for debugging any issues with conda
  - conda info -a
  - conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION numpy scipy scikit-learn matplotlib
  - source activate test-environment
  - conda list
  - python --version
  - whereis python
  - python setup.py install
script: nosetests

【问题讨论】:

  • travis 默认使用 virtualenv for python,which python 的输出是什么?
  • /home/travis/miniconda/envs/test-environment/bin/python 在使用 conda 创建另一个 virtualenv 之后。 Here is the new build.

标签: python scipy travis-ci miniconda


【解决方案1】:

您的 python 与 travis 日志中看到的虚拟环境不对应。猜测一下,我会说nosetests 正在使用它自己的venv。

所以看看nosetests:它可能有一个不同的硬编码shebang作为第一行(head -n1 $(which nosetests)可能会这样做),因此使用不同的python和不同的venv。

如果以上是正确的,解决方案可能是安装你自己版本的nosetests。这应该优先(在你的 PATH 中更早)。

【讨论】:

  • 就是这样。我通过 conda 安装 nose 之前和之后的 shebang 行是不同的。现在一切正常。谢谢!
  • 补充一下,但这更多的是猜测:默认的 travis VM 可能设置了一组标准的实用程序,而 nosetests 恰好是其中之一。我想带回家的信息是“始终明确您需要自己的任何东西”。或者更确切地说,这在很大程度上一直是我的座右铭:-)。
  • 确实,nosetests 是 Python VM 中的默认实用程序,如 here 所示。我已经吸取了教训:从现在开始,将我要使用的所有内容都明确化。
猜你喜欢
  • 2021-04-04
  • 2015-08-30
  • 1970-01-01
  • 2014-11-15
  • 2021-04-01
  • 1970-01-01
  • 2014-09-08
  • 2020-01-21
  • 2018-02-03
相关资源
最近更新 更多