简体   繁体   中英

Specifying python version when using `generic` image in travis-ci for a project with both C and Python

I have a project using both C (and the GSL library) and Python. I am hoping to run tests in Python after installing the GSL library. Travis-CI allows generic images which include both the gcc compiler and Python so this sounds ideal for this project. I cannot seem to specify the Python version to use for pip and python calls. The following .travis.yml build fails and the log shows that pytest is using Python 2.7. I've tried python3 -m pytest and also tried using pip3 but neither has worked. How can I specify the version of python (3.6.2) so that both pip install modules for this version of python and pytest is run for this version of python under the generic image?

Many thanks in advance for the help.

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

If you have python3 and pip3 that means pytest is for python 2 like python and pip

Install python3-pytest then specify pytest-3 rather than pytest for the script , probably also use pip3 rather than pip for install

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM