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

Solution: Import the 'AF_INET' module

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

from socket import AF_INET

 

For more information:
Python socket AF_INET