ImportError: cannot import name 'ELOCKUNMAPPED' from 'errno' (unknown location)

I am creating a bot where I can add ELO, I keep getting this error called “ImportError: cannot import name ‘ELOCKUNMAPPED’ from ‘errno’ (unknown location)”. Can someone help me import this? I tried Googling this but I did not find anything.

You need to show your code or we have to guess what you are doing.

What makes you think that errno has that symbol defined?
I am guessing you are coding for a symbol that does not exist in python’s errno module.

from errno import ELOCKUNMAPPED
import discord
from discord.ext import commands
client = commands.Bot(command_prefix='!', intents=discord.Intents.all())

# create a new ELO rating system with a starting rating of 1200
rating_system = ELOCKUNMAPPED.Rating(1200)
async def win(ctx, player: discord.Member):
    # add 1 point to the winner's ELO rating
    rating_system.update_rating(, 1)
    await ctx.send(f'{player.mention} has won! Their new rating is {rating_system.get_rating(}')

async def lose(ctx, player: discord.Member):
    # subtract 1 point from the loser's ELO rating
    rating_system.update_rating(, 0)
    await ctx.send(f'{player.mention} has lost! Their new rating is {rating_system.get_rating(}')'this is where the discord key goes')

Per the docs, there is no such symbol documented in errno in any current version of Python, nor any symbol I can find with a similar name.

Furthermore, you then do

Which doesn’t make any conceivable sense; the value of the error codes in errno are simply regular Python integers, which have no Rating method much less one that could somehow create an Elo ranking system for you.

You might want to search on PyPI for a Python package that implements an Elo system and start from there.

Also, when adding code or output to your post, please make sure you enclose it in code fencing so it is formatted correctly for others to read and copy, as I’ve done for you this time. You can do so with the </> button in the toolbar, or via typing triple backticks above and below the code in question, optionally with the language name (e.g. python) for syntax highlighting, like this:


I don’t know whether you’re trusting too much in a tab completion system (or worse), but “ELO” does not mean “search the standard library for any symbol beginning with the letters ELO and use that”.

In any case, it’s “Elo”, not “ELO”. It’s not an acronym.

You may need to do some research to find out how an Elo system actually works. The mathematics behind it aren’t complicated.

1 Like

Oh wow…I was baffled by how they could have written the code they did, but it didn’t cross my mind to think of someone actually doing that (especially since, as far as I can tell, ELOCKUNMAPPED isn’t even a documented errno code on any version of Python I checked).

Or maybe it was AI-generated to a prompt that was something like “implement a Discord bot with an Elo system”?

ELOCKUNMAPPED exists, but my search only turned up 1 reference other than this doc and this issue.

Josh, did you write this code yourself or quote it from somewhere?

ELOCKUNMAPPED does seem to be a valid errno, just not in Python; it definitely has the look of code that was made with an aggressive tab completion system. (You should see some of the horrors that come out of Chrome Developer Tools when you misspell something and just hit Enter. It’s even harder to spot there, because it’s case sensitive and will search within the word rather than only as a prefix. I tried typing “ELO” and hitting Enter, and got the function WakeLock.)

But Elo systems probably DO exist on PyPI, so it’s possible that the OP meant to import something completely unrelated… and then tab completed to the wrong thing.

After some googling, perhaps this is the package you mean to import, or another one of the many like it, and you intended to type something like

from elo_rating import Elo

or similar. You’ll need to check the documentation of the package you intend to use to confirm.

I am so looking forward to bug reports that say “ChatGPT said to do this, but it doesn’t work. Python is broken.”