I'm trying to get the IP address and MAC address of my pc's network card by python. I got some code from here
I create a proj "getip". create "main.py". And I modify the code of "main.py" as follow
from netifaces import interfaces, ifaddresses, AF_INET
def ip4_addresses():
ip_list = []
for interface in interfaces():
for link in ifaddresses(interface)[AF_INET]:
ip_list.append(link['addr'])
return ip_list
def main():
print ip4_addresses()
if __name__ == "__main__":
main()
and I create "app.yaml"
application: getip
version: 1
runtime: python
api_version: 1
handlers:
- url: .*
script: main.py
and when I run the main.py at console as "python main.py", I got the ip addresses.
and when I run as "dev_appserver.py getip", the server is setup. When I browse the page as localhost:8080, the web page is white screen and I got the following error at console.
from netifaces import interfaces, ifaddresses, AF_INET
ImportError: No module named netifaces
How can I solve the problem?
just install netifaces
pip install netifaces
if you have pip installed, or download the source, unpack it run and python setup.py install
warning: this will install it globally on your system, so use caution, or use virtualenv
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With