同一段python代码在windows下能运行,在ubuntu下不行,socket相关,该怎么处理

同一段python代码在windows下能运行,在ubuntu下不行,socket相关
代码如下:
import socket
def main():
  host=socket.gethostname()
  print host
if __name__ == '__main__':
  main()
windows下正常运行,但是在ubuntu下显示AttributeError: 'module' object has no attribute 'gethostname'
这是为什么

------解决方案--------------------
python版本不一致