Does anyone know how to find the Local IPv4 address of the same device, running python code?
I was able to find this on google:
socket.gethostbyname(socket.gethostname()). It works on my personal laptop, and returns
192.168.1.130. But returns the following error when ran on a RaspberryPI 3 B+ through the Balena dashboard:
opencv-test Traceback (most recent call last): opencv-test File "./main.py", line 51, in <module> opencv-test init() opencv-test File "./main.py", line 39, in init opencv-test ip = socket.gethostbyname(socket.gethostname()) opencv-test socket.gaierror: [Errno -5] No address associated with hostname
Does anyone know how to associate the IP address with the
hostname, or if there is another way of retrieving the address?