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


i have following code in order create socket:

#!/usr/bin/python  import socket import sys  try:         s = socket.socket(socket.af_inet, socket.sock_stream) except socket.error, msg:         print 'failed create socket. error code: ' + str(msg[0]) + ' error message: ' + msg[1]         sys.exit(); print 'socket created!' 

but have following error:

attributeerror: 'module' object has no attribute 'error' 

you have different module named socket on path. did not import stdlib module because being masked.

print out filename of masking module locate it, rename it:

print socket.__file__ 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -