Forum Archive

Socket inet_pton() is not included

bar4mi

First of all, I'm not good at Pythonista. I moved netaddr module to site-packages-2 after downloading it using pipista. When I import netaddr, I get an Error below. I found the default socket.py module has no inet_pton(). I'm wondering why socket.py has no inet_pton and how to solve this problem. I need your advice.

from socket import inet_pton as _inet_pton, AF_INET
ImportError: cannot import name inet_pton

dgelessus

FWIW, under Python 3 socket.inet_pton and socket.inet_ntop exist. Under Python 2 they don't for some reason.

The netaddr library seems to be compatible with Python 2 and 3, so maybe you can get it to work under Python 3.

bar4mi

Thank you for your kind reply. As your information, it's just time for me to migrate to Python 3.x.