首页 > 解决方案 > tox 运行错误的 Python 版本

问题描述

这是我的 tox.ini 文件:

dino@DINO:~/code/mplfinance$ cat tox.ini

[tox]
envlist = py36, py37, py38

[pytest]
python_files = tests.py

[testenv]
deps =
    matplotlib
    numpy
    pandas
    pytest
setenv =
    # don't use interactive backend for matplotlib in e2e tests
    MPLBACKEND = agg
commands =
    pytest

当我运行tox<Enter>它时,它会为指定的三个环境中的每一个启动 pytest。当 pytest 首次启动时(对于每个环境),它会报告 Python 的版本和它正在使用的其他一些东西。例如,py36我看到:

py36 runtests: PYTHONHASHSEED='893013612'
py36 runtests: commands[0] | pytest
============= test session starts ==============
platform linux -- Python 3.6.7, pytest-5.4.1, py-1.8.1, pluggy-0.13.1
rootdir: /home/dino/code/mplfinance, inifile: tox.ini
collected 2 items

tests.py ..                               [100%]

=========== 2 passed in 13.48s     ==============

它说py36 runtests: ...,然后它说platform linux -- Python 3.6.7, ...一切都很好。

同样,我看到

py37 runtests: PYTHONHASHSEED='893013612'
py37 runtests: commands[0] | pytest
======================== test session starts ==================
platform linux -- Python 3.7.4, ...

一切都好。


问题是,当谈到 py38 时,我看到:

py38 runtests: PYTHONHASHSEED='893013612'
py38 runtests: commands[0] | pytest
============ test session starts ==================
platform linux -- Python 3.6.7, pytest-5.4.1, py-1.8.1, pluggy-0.13.1
rootdir: /home/dino/code/mplfinance, inifile: tox.ini
collected 2 items

tests.py ..                                               [100%]

============== 2 passed in 16.19s ====================

为什么我看到Python 3.6.7???py38我在这里做错了吗?

非常感谢您的帮助!


对于它的价值,这是我运行 WSL 的一般环境信息:

dino@DINO:~/code/mplfinance$ cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.2 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.2 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

dino@DINO:~/code/mplfinance$ uname -a
Linux DINO 4.4.0-18362-Microsoft #476-Microsoft Fri Nov 01 16:53:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux

dino@DINO:~/code/mplfinance$ python --version
Python 3.7.4

标签: pytestcondatox

解决方案


推荐阅读