AttributeError: 'module' object has no attribute

user3676491

Trying to program a socket in python but keep getting attribute errors every time I try to use the socket module. The attributes should be there. They are rather basic things. I have at this point just copy and pasted tutorial code and still it gives me error.

Traceback (most recent call last):
  File "C:\Users\micheal\workspace\GCNSocket\socket\GCNSocket.py", line 18, in <module>
    except socket.error, msg:
AttributeError: 'module' object has no attribute 'error'

and my code is

import time
import socket
import sys

host_ip="209.208.78.170"
port=8099                   
if __name__ == "__main__":
   currentTime=time.time() #current time (time)
   lastTime=time.time() #records last time of last received packet (time)

   try:
       mySocket=socket.socket(socket.AF_INET,socket.SOCK_STREAM) # create socket
   except socket.error, msg:
      print ('Failed to create socket. Error code: ' + str(msg[0]) + ' , Error message : ' + msg[1])
      sys.exit()

  print("Starting Connection")
  if(mySocket.connect((host_ip,port))): #connect
       print("Connected to 209.208.78.170  port 8099")
  else:
       print("Unable to Connect")

If I remove the try block and just create the socket, I get same error with 'socket' instead of 'error'

falsetru

You're using socket as a package name. It cause import of your package socket instead of standard library module socket.

Rename it so it does not collide with standard library module name.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

AttributeError: 'module' object has no attribute

From Dev

AttributeError: 'module' object has no attribute

From Dev

AttributeError:'module' object has no attribute 'call' :Python

From Dev

AttributeError: 'module' object has no attribute 'tk'

From Dev

AttributeError: 'module' object has no attribute 'cache'

From Java

AttributeError: 'module' object has no attribute 'tests'

From Dev

AttributeError: 'module' object has no attribute 'TestCase'

From Dev

AttributeError: 'module' object has no attribute 'version'

From Dev

Mtaplotlib AttributeError: 'module' object has no attribute 'pyplot'

From Dev

AttributeError: 'module' object has no attribute 'plotting'

From Java

AttributeError: 'module' object has no attribute 'request'

From Java

tensorflow:AttributeError: 'module' object has no attribute 'mul'

From Java

AttributeError: 'module' object has no attribute 'urlretrieve'

From Dev

AttributeError: 'module' object has no attribute 'grd'

From Dev

AttributeError: 'module' object has no attribute 'SignedJwtAssertionCredentials'

From Dev

AttributeError: 'module' object has no attribute 'scandir'

From Dev

AttributeError: 'module' object has no attribute 'SFrame'

From Dev

Pylint AttributeError: 'module' object has no attribute 'append'

From Dev

Inheritance AttributeError: 'module' object has no attribute

From Dev

AttributeError: 'module' object has no attribute 'ORB'

From Dev

AttributeError: 'module' object has no attribute 'utcnow'

From Dev

AttributeError: "'module' object has no attribute 'ARRAY'"

From Dev

AttributeError: 'module' object has no attribute 'div'

From Dev

Python AttributeError: 'module' object has no attribute 'atoi'

From Dev

AttributeError: 'module' object has no attribute 'EmailInput'

From Dev

python - AttributeError: 'module' object has no attribute 'lock'

From Dev

AttributeError: 'module' object has no attribute '[x]'

From Dev

Pygame AttributeError: 'module' object has no attribute 'copy'

From Dev

SQLAlchemy AttributeError: 'module' object has no attribute 'PandasSQLAlchemy'

Related Related

  1. 1

    AttributeError: 'module' object has no attribute

  2. 2

    AttributeError: 'module' object has no attribute

  3. 3

    AttributeError:'module' object has no attribute 'call' :Python

  4. 4

    AttributeError: 'module' object has no attribute 'tk'

  5. 5

    AttributeError: 'module' object has no attribute 'cache'

  6. 6

    AttributeError: 'module' object has no attribute 'tests'

  7. 7

    AttributeError: 'module' object has no attribute 'TestCase'

  8. 8

    AttributeError: 'module' object has no attribute 'version'

  9. 9

    Mtaplotlib AttributeError: 'module' object has no attribute 'pyplot'

  10. 10

    AttributeError: 'module' object has no attribute 'plotting'

  11. 11

    AttributeError: 'module' object has no attribute 'request'

  12. 12

    tensorflow:AttributeError: 'module' object has no attribute 'mul'

  13. 13

    AttributeError: 'module' object has no attribute 'urlretrieve'

  14. 14

    AttributeError: 'module' object has no attribute 'grd'

  15. 15

    AttributeError: 'module' object has no attribute 'SignedJwtAssertionCredentials'

  16. 16

    AttributeError: 'module' object has no attribute 'scandir'

  17. 17

    AttributeError: 'module' object has no attribute 'SFrame'

  18. 18

    Pylint AttributeError: 'module' object has no attribute 'append'

  19. 19

    Inheritance AttributeError: 'module' object has no attribute

  20. 20

    AttributeError: 'module' object has no attribute 'ORB'

  21. 21

    AttributeError: 'module' object has no attribute 'utcnow'

  22. 22

    AttributeError: "'module' object has no attribute 'ARRAY'"

  23. 23

    AttributeError: 'module' object has no attribute 'div'

  24. 24

    Python AttributeError: 'module' object has no attribute 'atoi'

  25. 25

    AttributeError: 'module' object has no attribute 'EmailInput'

  26. 26

    python - AttributeError: 'module' object has no attribute 'lock'

  27. 27

    AttributeError: 'module' object has no attribute '[x]'

  28. 28

    Pygame AttributeError: 'module' object has no attribute 'copy'

  29. 29

    SQLAlchemy AttributeError: 'module' object has no attribute 'PandasSQLAlchemy'

HotTag

Archive