[英]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.我有一个同时使用 C(和 GSL 库)和 Python 的项目。 I am hoping to run tests in Python after installing the GSL library.
我希望在安装 GSL 库后在 Python 中运行测试。 Travis-CI allows
generic
images which include both the gcc
compiler and Python so this sounds ideal for this project. Travis-CI 允许包含
gcc
编译器和 Python 的generic
图像,所以这听起来非常适合这个项目。 I cannot seem to specify the Python version to use for pip
and python
calls.我似乎无法指定用于
pip
和python
调用的 Python 版本。 The following .travis.yml
build fails and the log shows that pytest is using Python 2.7.以下
.travis.yml
构建失败,日志显示 pytest 使用的是 Python 2.7。 I've tried python3 -m pytest
and also tried using pip3
but neither has worked.我试过
python3 -m pytest
也试过使用pip3
但都没有奏效。 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?如何指定 python (3.6.2) 的版本,以便在
generic
映像下为此版本的 python 运行 pip install 模块和 pytest?
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如果你有python3和pip3这意味着pytest适用于python 2,如python和pip
Install python3-pytest then specify pytest-3 rather than pytest for the script , probably also use pip3 rather than pip for install安装python3-pytest然后为脚本指定pytest-3而不是pytest ,可能也使用pip3而不是pip进行安装
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.