One more thing to try:
In the shell, run the following commands and report back what the results are:
(No output is expected from this first command)
import socket
socket.gethostname()
socket.getfqdn()
socket.getfqdn('127.0.0.1')
(Side note: I cribbed this from Encoding with 'idna' codec failed (UnicodeError: label empty or too long) - #12 by KenWhitesell)