AttributeError: module 'glicko2' has no attribute 'Rating'

I successfully imported the glicko2 package. However when I tried to call the Rating function in glicko2, I end up with the below error feedback

import glicko2 as gl2
gl2.Rating

I am very new to python. Can someone please help me out

1 Like

Hi Benjamin,

Is this you?

I will second the advice there:

  • double check that your script isn’t called “glicko2”.

That is the single most common cause of the sort of error you are
getting. Once you have double checked that, make sure there are no other
files floating around called “glicko2.py” or “glicko2.pyc”. If there
are, rename them.

If that doesn’t solve the problem, do this:

import glicko2
print(glicko2.__file__)

Note that there are two underscores before and after the word “file”.
What does it say?

Last but not least, how did you install glicko2 and where did you get it
from? Unfortunately there seems to be a couple of different libraries
named glicko2, I have found at least two, looking at the source code
they are radically different and I cannot tell which one is correct or
better.

This one has a Rating class:

This one is on PyPi, so it’s probably the one you got:

but it has no Rating.

So unfortunately it looks to me like there are at least two, and maybe
more, radically different and incompatible libraries called “glicko2”,
some which have Rating and some which don’t. Which one you get will
depend on how you installed it.

1 Like

Thank you @steven.daprano for the support. The problem has to do with the glicko2 package I installed. I installed the Pypi package which has no attribute “Rating”. Thank you for pointing this out. Problem solved. Appreciated

1 Like