Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python attribute error: type object '_socketobject' has no attribute 'gethostbyname'

I am trying to do this in my program:

dest = socket.gethostbyname(host)

I have included the line:

from socket import * 

in the beginning of the file.

I am getting this error:

AttributeError: type object '_socketobject' has no attribute 'gethostbyname'

I am running Vista 64bit. Could there be a problem with my OS? I have turned down my firewall and everything.

like image 380
Sheela Avatar asked Dec 07 '09 00:12

Sheela


1 Answers

You shoulod either use

import socket
dest = socket.gethostbyname(host)

or use

from socket import *
dest = gethostbyname(host)

Note: the first option is by far the recommended one.

like image 70
rob Avatar answered Oct 06 '22 09:10

rob