'How can I get the Public Ip address of my computer without reading text from a url?

I would like to get the Public Ip address of my computer.

Many solutions I have seen require requests/urllib2, such as:

import requests
requests.get('http://ip.42.pl/raw').text
import requests

public_IP = requests.get("https://www.wikipedia.org").headers["X-Client-IP"]
print(public_IP)
from json import load
from urllib2 import urlopen

my_ip = load(urlopen('http://httpbin.org/ip'))['origin']

Reference link: How can I get the public IP using python2.7? (Python version doesn't really matter at the moment)

Is there any way to get the public IP without using requests or similar libraries?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source