【发布时间】:2019-02-17 10:17:57
【问题描述】:
我想在 Travis CI 构建环境中运行一个简单的 Python 3 脚本。
我按照 Travis CI Python 指南 (https://docs.travis-ci.com/user/languages/python) 创建了一个初始 .travis.yml 文件。
Travis CI 在单独的 virtualenv 中针对 YML 文件中描述的 Python 版本运行每个构建。
我的脚本依赖于requests 模块,我将它添加到requirements.txt 文件中并pip 将其安装在Travis CI 中,但是一旦脚本运行,脚本就无法导入该模块。
错误
./benchmark.py https://graph.irail.be/sncb/connections -n 10 -i -o results.csv
Traceback (most recent call last):
File "./benchmark.py", line 3, in <module>
import requests
ImportError: No module named 'requests'
.travis.yml
language: python
python:
- "3.3"
- "3.4"
- "3.5"
- "3.6"
# command to install deps
install:
- pip install -r requirements.txt
# run build
script:
- ./benchmark.py https://graph.irail.be/sncb/connections -n 10 -i -o results.csv
我的 Github 仓库:https://github.com/DylanVanAssche/http-benchmark/tree/feature/CI
我的 Travis CI 构建:https://travis-ci.com/DylanVanAssche/http-benchmark/jobs/145320050
【问题讨论】:
标签: python python-requests travis-ci