Unable to open anki app on Win10 "UnicodeError: encoding with 'idna' codec failed (UnicodeError: label empty or too long)"

I installed anki app on windows 2.1.37-windows for the very first time on Windows 10 19042.685 but it displays the following:

[12696] LOADER: Running runanki.py
Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\python\lib\encodings\idna.py", line 165, in encode
UnicodeError: label empty or too long

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "threading.py", line 932, in _bootstrap_inner
  File "aqt\mediasrv.py", line 67, in run
  File "waitress\server.py", line 81, in create_server
  File "waitress\server.py", line 242, in __init__
  File "waitress\server.py", line 270, in get_server_name
UnicodeError: encoding with 'idna' codec failed (UnicodeError: label empty or too long)
mpv too old for key rebinding

I also tried 2.1.35-windows-alternate 32 bit but it displays the following:

[3100] LOADER: Running runanki.py
Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\python38\lib\encodings\idna.py", line 165, in encode
UnicodeError: label empty or too long

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "threading.py", line 932, in _bootstrap_inner
  File "aqt\mediasrv.py", line 63, in run
  File "lib\site-packages\waitress\server.py", line 81, in create_server
  File "lib\site-packages\waitress\server.py", line 242, in __init__
mpv not found, reverting to mplayer
  File "lib\site-packages\waitress\server.py", line 270, in get_server_name
UnicodeError: encoding with 'idna' codec failed (UnicodeError: label empty or too long)

It works fine on another Win 10 laptop. What could be the cause?

It’s likely related to your hosts file.


C:\Users\stevewinter>hostname
WINDOWS10

I’ve added 0.0.0.0 Windows10 to the top of the list and now everything functions as expected.

OK, once I commented out youtube ips it works fine on my admin account. But why would that matter?

#127.0.0.1 .youtube_dot_com
#127.0.0.1 youtube_dot_com
#127.0.0.1 www.youtube_dot_com
#127.0.0.1 m.youtube_dot_com
#127.0.0.1 .youtu_dot_be
#127.0.0.1 .youtube-nocookie.com
#127.0.0.1 .manhuascan_dot_com
#127.0.0.1 manhuascan_dot_com

Now when I start the app on my daughter’s account I get this error:
anki-error

For this issue, please see Bug (minor): "Failed to create OpenGL context" after first start

Sure enough, when I restarted the app it worked. Thank you. Still not sure why those domains in hosts needed to be commented out but glad it’s working. Thanks.

I suspect the leading dots are causing the problem, as they do not look like a valid hostname. The latest beta version of Anki may be more tolerant of this.

1 Like