"import socket" error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • akbarhome@gmail.com

    "import socket" error

    Hi,

    I am following this tutorial

    ( free reg. req. )

    The article told me to do this:

    [camus]$ python
    Python 2.4 (#1, Feb 20 2005, 11:25:45)
    [GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2
    Type "help", "copyright" , "credits" or "license" for more
    information.[color=blue][color=green][color=darkred]
    >>> import socket
    >>> socket.gethostb yname('www.ibm. com')[/color][/color][/color]
    '129.42.19.99'[color=blue][color=green][color=darkred]
    >>>[/color][/color][/color]

    When I try it, I get this error:[color=blue][color=green][color=darkred]
    >>> import socket[/color][/color][/color]
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    File "/usr/lib/python2.4/socket.py", line 1, in ?
    # Wrapper module for _socket, providing some additional facilities
    File "/usr/lib/python2.4/SocketServer.py ", line 274, in ?
    class TCPServer(BaseS erver):
    File "/usr/lib/python2.4/SocketServer.py ", line 317, in TCPServer
    address_family = socket.AF_INET
    AttributeError: 'module' object has no attribute 'AF_INET'[color=blue][color=green][color=darkred]
    >>>[/color][/color][/color]


    Why? Thank you.

  • Fredrik Lundh

    #2
    Re: &quot;import socket&quot; error

    akbarhome@gmail .com wrote:
    [color=blue]
    > I am following this tutorial
    >[/color]
    https://www14.software.ibm.com/webap...7PythonSockets[color=blue]
    > ( free reg. req. )
    >
    > The article told me to do this:
    >
    > [camus]$ python
    > Python 2.4 (#1, Feb 20 2005, 11:25:45)
    > [GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2
    > Type "help", "copyright" , "credits" or "license" for more
    > information.[color=green][color=darkred]
    > >>> import socket
    > >>> socket.gethostb yname('www.ibm. com')[/color][/color]
    > '129.42.19.99'[color=green][color=darkred]
    > >>>[/color][/color]
    >
    > When I try it, I get this error:[color=green][color=darkred]
    > >>> import socket[/color][/color]
    > Traceback (most recent call last):
    > File "<stdin>", line 1, in ?
    > File "/usr/lib/python2.4/socket.py", line 1, in ?
    > # Wrapper module for _socket, providing some additional facilities
    > File "/usr/lib/python2.4/SocketServer.py ", line 274, in ?
    > class TCPServer(BaseS erver):
    > File "/usr/lib/python2.4/SocketServer.py ", line 317, in TCPServer
    > address_family = socket.AF_INET
    > AttributeError: 'module' object has no attribute 'AF_INET'[color=green][color=darkred]
    > >>>[/color][/color]
    >
    > Why? Thank you.[/color]

    your Python installation is broken. what OS are you using?

    </F>



    Comment

    • akbar

      #3
      Re: &quot;import socket&quot; error

      Fedora Core 4.

      Comment

      Working...