votes up 1

Not a valid numpy version string

Package:
numpy
github stars 18118
Exception Class:
ValueError

Raise code

""" 

    """

    def __init__(self, vstring):
        self.vstring = vstring
        ver_main = re.match(r'\d\.\d+\.\d+', vstring)
        if not ver_main:
            raise ValueError("Not a valid numpy version string")

        self.version = ver_main.group()
        self.major, self.minor, self.bugfix = [int(x) for x in
            self.version.split('.')]
        if len(vstring) == ver_main.end():
            self.pre_release = 'final'
        else:
😲 Agile task management is now easier than calling a taxi. #Tracklify
🙏 Scream for help to Ukraine
Today, 2nd July 2022, Russia continues bombing and firing Ukraine. Don't trust Russia, they are bombing us and brazenly lying in same time they are not doing this 😠, civilians and children are dying too! We are screaming and asking exactly you to help us, we want to survive, our families, children, older ones.
Please spread the information, and ask your governemnt to stop Russia by any means. We promise to work extrahard after survival to make the world safer place for all.

Ways to fix

votes up 7 votes down

Summary: In order to avoid this exception, make sure the NumPy version passed as a parameter is valid. It must be a digit followed by a period, followed by one or more digits followed by another period, and end with one or more digits.

For example: 
	1.9.0 or 1.19.3 are Valid 
	But 1.3 or 1.9.0. (with an extra period in the end) are Invalid

Code to Reproduce the Error (WRONG):

from numpy.lib import NumpyVersion
# Missing third digit or group of digits
nv = NumpyVersion('1.9')

Working Version (Fixed):

from numpy.lib import NumpyVersion
nv = NumpyVersion('1.9.0')

Jul 03, 2021 codingcomedyig answer

Add a possible fix

Please authorize to post fix