I can't import socket module into my program. When I import it said, "AttributeError: 'module' object has no attribute "AF_INET'.
I think there is a problem with my python virtual machine.
-
2A common problem is naming your file something that would cross with the module. What did you name your file? Also, could you post your code?TerryA– TerryA2013年01月27日 06:50:29 +00:00Commented Jan 27, 2013 at 6:50
2 Answers 2
Mostly It is looking like Either naming problem or path problem.You can try to run your program from another location as did by this Python Socket Problem
Or if it is a naming problem then maybe you are using some standard names in your code, which are clashes with system ones Socket isn't working in Python and Python Error
Comments
Rule of thumb in users' created python modules, never give your modules the same python's standard modules names; instant conflict will occur.
eg. If you name your socket app "socket.py", and started your application, similar problem to what you showed will appear.