我想在 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.csvTraceback (most recent call last):File "./benchmark.py", line 3, in <module> import requestsImportError: No module named 'requests'.travis.ymllanguage: pythonpython: - "3.3" - "3.4" - "3.5" - "3.6"# command to install depsinstall: - pip install -r requirements.txt# run buildscript: - ./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
1 回答

MMTTMM
TA贡献1869条经验 获得超4个赞
您需要专门调用python3 <filename>
以确保您使用的是python3。我不确定为什么会发生这种情况,但显然该#!/usr/bin/python3
指令不足以加载正确的模块。
添加回答
举报
0/150
提交
取消