【发布时间】:2015-07-28 22:10:25
【问题描述】:
我是第一次设置 Travis-CI。我以我认为是标准的方式安装 scipy:
language: python
python:
- "2.7"
# command to install dependencies
before_install:
- sudo apt-get -qq update
- sudo apt-get -qq install python-numpy python-scipy python-opencv
- sudo apt-get -qq install libhdf5-serial-dev hdf5-tools
install:
- "pip install numexpr"
- "pip install cython"
- "pip install -r requirements.txt --use-mirrors"
# command to run tests
script: nosetests
一切都建立起来。但是当鼻子测试开始时,我得到了
ImportError: No module named scipy.ndimage
更新:这里有一个更直接的问题演示。
$ sudo apt-get install python-numpy python-scipy python-opencv
$ python -c 'import scipy'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named scipy
The command "python -c 'import scipy'" failed and exited with 1 during install.
我也尝试使用 pip 安装 scipy。我尝试先安装 gfortran。 Here is one example of a failed build。有什么建议吗?
另一个更新:Travis 已经添加了关于在 Travis 中使用 conda 的官方文档。请参阅 ostrokach 的回答。
【问题讨论】:
-
当您从
sudo apt-get install python-scipy中删除-qq选项时,您是否看到任何有趣的消息?如果你打开一个终端,你能import scipy.ndimage吗? -
我删除了
-qq(see latest build here),我没有看到有问题的消息。如果我在我的电脑上打开一个终端,是的,我可以import scipy.ndimage。但也许我误解了你:有什么方法可以在 Travis 中打开终端吗? -
对不起,丹,我不知道。只是 scipy 引发了导入错误,还是 numpy、cv 等也引发了
ImportErrors? -
好建议。 Numpy 很好,但 cv 和 cv2 也会引发 ImportErrors。我不确定我们在这里学到了什么,但这不仅仅是 scipy 的错。
-
如果您查看
pip命令的失败日志,您将看到 Travis CI 正在虚拟环境中安装 numexpr/cypthon/etc。所以我的猜测是sudo apt-get install命令正在为系统的python安装scipy和friends,但是Travis CI环境正在使用virtualenv的python进行nosetest,它无法访问系统的包。我知道您已经尝试过使用 pip 安装 scipy,但也许可以使用 this 作为指导再试一次。