How to Solve NameError: name 'socket' is not defined -- socket

Solution: Import the 'socket' module

To Solve the error, add the following line to the top of your code.

from socket import socket

 

For more information:
Python socket socket