python 版本号比较有问题 check.py

今天调试代码,总感觉标红的部分,版本号比较会有问题的,比如1.6.1与1.11.3,这样的版本号比较LooseVersion(mx.__version__) < LooseVersion(mx_version),就比较不出来了,不知道是不是python版本号中间位置没有两位数,有大神能给解释一下吗?
"""Pre init checks"""
import sys

def _require_mxnet_version(mx_version, max_mx_version='2.0.0'):
    try:
        import mxnet as mx
        from distutils.version import LooseVersion
        if LooseVersion(mx.__version__) < LooseVersion(mx_version) or \
            LooseVersion(mx.__version__) >= LooseVersion(max_mx_version):
            version_str = '>={},<{}'.format(mx_version, max_mx_version)
            msg = (
                "Legacy mxnet=={0} detected, some modules may not work properly. "
                "mxnet{1} is required. You can use pip to upgrade mxnet "
                "`pip install -U 'mxnet{1}'` "
                "or `pip install -U 'mxnet-cu100{1}'`\
                ").format(mx.__version__, version_str)
            raise RuntimeError(msg)
    except ImportError:
        raise ImportError(
            "Unable to import dependency mxnet. "
            "A quick tip is to install via "
            "`pip install 'mxnet-cu100<{}'`. "
            "please refer to https://gluon-cv.mxnet.io/#installation for details.".format(
                max_mx_version))

def _require_pytorch_version(torch_version, max_torch_version='2.0.0'):
    try:
        import torch
        from distutils.version import LooseVersion
        if LooseVersion(torch.__version__) < LooseVersion(torch_version) or \
            LooseVersion(torch.__version__) >= LooseVersion(max_torch_version):
            version_str = '>={},<{}'.format(torch_version, max_torch_version)
            msg = (
                "Legacy torch=={0} detected, some modules may not work properly. "
                "torch{1} is required. You can use pip or conda to upgrade")
            raise RuntimeError(msg)
    except ImportError:
        raise ImportError(
            "Unable to import dependency pytorch. Please use pip or conda to install.")

def _deprecate_python2():
    if sys.version_info[0] < 3:
        msg = 'Python2 has reached the end of its life on January 1st, 2020. ' + \
            'GluonCV has now dropped support for Python 2.'
        raise DeprecationWarning(msg)

你可能感兴趣的:(python,python)