Odd, it looks like the hostname (localhost) could not be resolved. Could you run the following and post the results from your machine:
>>> import socket
>>> socket.getaddrinfo('localhost', 27017, socket.AF_INET, socket.SOCK_STREAM)
[(2, 1, 6, '', ('127.0.0.1', 27017))]
>>> socket.getaddrinfo('localhost', 27017, socket.AF_UNSPEC, socket.SOCK_STREAM)
[(30, 1, 6, '', ('::1', 27017, 0, 0)), (2, 1, 6, '', ('127.0.0.1', 27017))]