votes up 3

invalid version number '%s'

github stars 49704
Exception Class:

Raise code

    version_re = re.compile(r'^(\d+) \. (\d+) (\. (\d+))? ([ab](\d+))?$',

    def parse(self, vstring):
        match = self.version_re.match(vstring)
        if not match:
            raise ValueError("invalid version number '%s'" % vstring)

        (major, minor, patch, prerelease, prerelease_num) = \
  , 2, 4, 5, 6)

        if patch:
            self.version = tuple(map(int, [major, minor, patch]))

Ways to fix

votes up 1 votes down

The exception is thrown when calling StrictVersion.

StrictVersion is version numbering. A version number consists of two or three dot-separated numeric components, with an optional "pre-release" tag on the end. The pre-release tag consists of the letter 'a' or 'b' followed by a number.

When you are using invalid version numbers, you will get an error.

Here is some invalid version numbers example:


To reproduce an error

from distutils.version import StrictVersion

version = StrictVersion('1.3.a4')

Fix code:

from distutils.version import StrictVersion

version = StrictVersion('0.9.6')
Jul 27, 2021 anonim answer
anonim 13.0k

Add a possible fix

Please authorize to post fix