[在travis-ci中为具有C和Python的项目使用`generic`图片时指定python版本

问题描述 投票:0回答:1

我有一个同时使用C(和GSL库)和Python的项目。我希望在安装GSL库后在Python中运行测试。 Travis-CI允许generic图像同时包含gcc编译器和Python,因此这对于该项目来说是理想的选择。我似乎无法指定用于pippython调用的Python版本。以下.travis.yml构建失败,并且日志显示pytest正在使用Python 2.7。我试过python3 -m pytest,也试过使用pip3,但都没有用。如何指定python(3.6.2)的版本,以便在generic映像下针对该版本的python运行该版本python和pytest的pip安装模块?

非常感谢您的帮助。

language: generic
dist: xenial
env: PYTHON_VERSION=3.6.2
python: 3.6
before_install: 
  - sudo apt-get install libgsl-dev
install:
  - pip install --user -r tests/requirements.txt
script:
  - pytest
python c unit-testing python-3.6 travis-ci
1个回答
0
投票

如果您有python3pip3,这意味着pytest适用于python 2,例如pythonpip

安装python3-pytest,然后为script指定pytest-3而不是pytest,可能还对pip3而不是pip 安装

© www.soinside.com 2019 - 2024. All rights reserved.